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.

2736 lines
81 KiB

  1. //// SETTINGS.CPP - Handles settings dialog
  2. //
  3. //
  4. #include "precomp.hxx"
  5. #include "global.h"
  6. #include <stdio.h>
  7. #include <tchar.h>
  8. //// HexToInt - convert hex digit string to int value
  9. //
  10. // Ignores 'x' in the string so accepts input like '0x0100'.
  11. int HexToInt(char szHex[]) {
  12. int i;
  13. int h;
  14. //int d;
  15. i = 0;
  16. h = 0;
  17. //d = 0;
  18. while (szHex[i] && szHex[i] != ' ') {
  19. if (szHex[i] >= '0' && szHex[i] <= '9') {
  20. h = h*16 + szHex[i] - '0';
  21. //d = d*10 + szHex[i] - '0';
  22. } else if (szHex[i] >= 'a' && szHex[i] <= 'f') {
  23. h = h*16 + 10 + szHex[i] - 'a';
  24. } else if (szHex[i] >= 'A' && szHex[i] <= 'F') {
  25. h = h*16 + 10 + szHex[i] - 'A';
  26. } else if (szHex[i] != ' ' && szHex[i] != ',' && szHex[i] != 'x' && szHex[i] != 'X') {
  27. return -1;
  28. }
  29. i++;
  30. }
  31. return h;
  32. }
  33. VOID GetTextForeGroundBrush(INT_PTR iBrushType)
  34. {
  35. if (g_textBrush)
  36. {
  37. delete g_textBrush;
  38. g_textBrush = NULL;
  39. }
  40. switch(iBrushType)
  41. {
  42. case 0: // Solid color
  43. {
  44. Color blackColor(g_TextColor);
  45. SolidBrush * blackBrush = new SolidBrush(blackColor);
  46. g_textBrush = (Brush *) blackBrush;
  47. }
  48. break;
  49. #ifndef USE_NEW_APIS3
  50. // rectangle, triangle and radiant gradient brushes are not available in v1.
  51. case 1: // RectGradient
  52. {
  53. RectF brushRect(0, 0, 32, 32);
  54. Color colors[5] = {
  55. Color(255, 255, 255, 255),
  56. Color(255, 255, 0, 0),
  57. Color(255, 0, 255, 0),
  58. Color(255, 0, 0, 255),
  59. Color(255, 0, 0, 0)
  60. };
  61. RectangleGradientBrush * rectGrad = new RectangleGradientBrush(brushRect, (Color*) &colors, WrapModeTile);
  62. g_textBrush = (Brush *) rectGrad;
  63. }
  64. break;
  65. case 2: // RadialGradient
  66. {
  67. RectF brushRect;
  68. Color centerColor(255, 255, 255, 255);
  69. Color boundaryColor(255, 0, 0, 0);
  70. brushRect.X = 0;
  71. brushRect.Y = 0;
  72. brushRect.Width = 60;
  73. brushRect.Height = 32;
  74. PointF center;
  75. center.X = brushRect.X + brushRect.Width/2;
  76. center.Y = brushRect.Y + brushRect.Height/2;
  77. RadialGradientBrush * radGrad = new RadialGradientBrush(brushRect, centerColor,
  78. boundaryColor, WrapModeTile);
  79. g_textBrush = (Brush *) radGrad;
  80. }
  81. break;
  82. case 3: // TriangleGradient
  83. {
  84. PointF points[7];
  85. points[0].X = 50;
  86. points[0].Y = 10;
  87. points[1].X = 200;
  88. points[1].Y = 20;
  89. points[2].X = 100;
  90. points[2].Y = 100;
  91. points[3].X = 30;
  92. points[3].Y = 120;
  93. Color colors[5] = {
  94. Color(255, 255, 255, 0),
  95. Color(255, 255, 0, 0),
  96. Color(255, 0, 255, 0),
  97. Color(255, 0, 0, 255),
  98. Color(255, 0, 0, 0)
  99. };
  100. TriangleGradientBrush * triGrad = new TriangleGradientBrush(points, (Color*) &colors, WrapModeTileFlipXY);
  101. g_textBrush = (Brush *) triGrad;
  102. }
  103. break;
  104. #endif
  105. case 4: // LineGradient
  106. {
  107. RectF lineRect(120, -20, 200, 60);
  108. Color color1(200, 255, 255, 0);
  109. Color color2(200, 0, 0, 255);
  110. LinearGradientBrush *lineGrad = new LinearGradientBrush(
  111. lineRect,
  112. color1,
  113. color2,
  114. LinearGradientModeForwardDiagonal
  115. );
  116. g_textBrush = (Brush *) lineGrad;
  117. }
  118. break;
  119. default: // Solid Color
  120. {
  121. Color blackColor(g_TextColor);
  122. SolidBrush * blackBrush = new SolidBrush(blackColor);
  123. g_textBrush = (Brush *) blackBrush;
  124. }
  125. break;
  126. }
  127. }
  128. VOID GetTextRenderingMode(INT_PTR iTextMode)
  129. {
  130. switch (iTextMode) {
  131. case 0: g_TextMode = TextRenderingHintSystemDefault; break;
  132. case 1: g_TextMode = TextRenderingHintSingleBitPerPixelGridFit; break;
  133. case 2: g_TextMode = TextRenderingHintSingleBitPerPixel; break;
  134. case 3: g_TextMode = TextRenderingHintAntiAliasGridFit; break;
  135. case 4: g_TextMode = TextRenderingHintAntiAlias; break;
  136. case 5: g_TextMode = TextRenderingHintClearTypeGridFit; break;
  137. default:g_TextMode = TextRenderingHintSystemDefault; break;
  138. }
  139. }
  140. VOID GetTextBackGroundBrush(INT_PTR iBrushType)
  141. {
  142. if (g_textBackBrush)
  143. {
  144. delete g_textBackBrush;
  145. g_textBackBrush = NULL;
  146. }
  147. switch(iBrushType)
  148. {
  149. case 0: // Solid color
  150. {
  151. Color blackColor(g_BackColor);
  152. SolidBrush * blackBrush = new SolidBrush(blackColor);
  153. g_textBackBrush = (Brush *) blackBrush;
  154. }
  155. break;
  156. #ifndef USE_NEW_APIS3
  157. // rectangle, triangle and radiant gradient brushes are not available in v1.
  158. case 1: // RectGradient
  159. {
  160. RectF brushRect(0, 0, 32, 32);
  161. Color colors[5] = {
  162. Color(255, 255, 255, 255),
  163. Color(255, 255, 0, 0),
  164. Color(255, 0, 255, 0),
  165. Color(255, 0, 0, 255),
  166. Color(255, 0, 0, 0)
  167. };
  168. RectangleGradientBrush * rectGrad = new RectangleGradientBrush(brushRect, (Color*) &colors, WrapModeTile);
  169. g_textBackBrush = (Brush *) rectGrad;
  170. }
  171. break;
  172. case 2: // RadialGradient
  173. {
  174. RectF brushRect;
  175. Color centerColor(255, 255, 255, 255);
  176. Color boundaryColor(255, 0, 0, 0);
  177. brushRect.X = 0;
  178. brushRect.Y = 0;
  179. brushRect.Width = 60;
  180. brushRect.Height = 32;
  181. PointF center;
  182. center.X = brushRect.X + brushRect.Width/2;
  183. center.Y = brushRect.Y + brushRect.Height/2;
  184. RadialGradientBrush * radGrad = new RadialGradientBrush(brushRect, centerColor,
  185. boundaryColor, WrapModeTile);
  186. g_textBackBrush = (Brush *) radGrad;
  187. }
  188. break;
  189. case 3: // TriangleGradient
  190. {
  191. PointF points[7];
  192. points[0].X = 50;
  193. points[0].Y = 10;
  194. points[1].X = 200;
  195. points[1].Y = 20;
  196. points[2].X = 100;
  197. points[2].Y = 100;
  198. points[3].X = 30;
  199. points[3].Y = 120;
  200. Color colors[5] = {
  201. Color(255, 255, 255, 0),
  202. Color(255, 255, 0, 0),
  203. Color(255, 0, 255, 0),
  204. Color(255, 0, 0, 255),
  205. Color(255, 0, 0, 0)
  206. };
  207. TriangleGradientBrush * triGrad = new TriangleGradientBrush(points, (Color*) &colors, WrapModeTileFlipXY);
  208. g_textBackBrush = (Brush *) triGrad;
  209. }
  210. break;
  211. #endif
  212. case 4: // LineGradient
  213. {
  214. RectF lineRect(120, -20, 200, 60);
  215. Color color1(200, 255, 255, 0);
  216. Color color2(200, 0, 0, 255);
  217. LinearGradientBrush *lineGrad = new LinearGradientBrush(
  218. lineRect,
  219. color1,
  220. color2,
  221. LinearGradientModeForwardDiagonal
  222. );
  223. g_textBackBrush = (Brush *) lineGrad;
  224. }
  225. break;
  226. default: // Solid Color
  227. {
  228. Color blackColor(g_BackColor);
  229. SolidBrush * blackBrush = new SolidBrush(blackColor);
  230. g_textBackBrush = (Brush *) blackBrush;
  231. }
  232. break;
  233. }
  234. }
  235. VOID GetDigitSubstituteMode (HWND hDlg, INT_PTR iDigitSubstituteType)
  236. {
  237. g_DigitSubstituteMode = (StringDigitSubstitute)iDigitSubstituteType;
  238. if(g_DigitSubstituteMode == StringDigitSubstituteUser || g_DigitSubstituteMode == StringDigitSubstituteNone)
  239. {
  240. EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGE) , FALSE);
  241. }
  242. else
  243. {
  244. EnableWindow(GetDlgItem(hDlg, IDC_LANGUAGE) , TRUE);
  245. }
  246. }
  247. BOOL ChangeFont(
  248. HWND hDlg,
  249. int iStyle,
  250. int idFont,
  251. int idSize,
  252. int idBold,
  253. int idItalic,
  254. int idUnderline,
  255. int idStrikeout,
  256. int iCmd,
  257. int iNotify
  258. )
  259. {
  260. int iHeight;
  261. char sFaceSize[100];
  262. TCHAR sFaceName[100];
  263. WPARAM i;
  264. // Get size
  265. if ( iCmd == idSize
  266. && iNotify == CBN_SELCHANGE)
  267. {
  268. i = SendDlgItemMessage(hDlg, idSize, CB_GETCURSEL, 0, 0);
  269. if (SendDlgItemMessageA(hDlg, idSize, CB_GETLBTEXT, i, (LPARAM)sFaceSize) == CB_ERR) {
  270. return FALSE;
  271. }
  272. }
  273. else
  274. {
  275. if (SendDlgItemMessageA(hDlg, idSize, WM_GETTEXT, sizeof(sFaceSize), (LPARAM)sFaceSize) == CB_ERR)
  276. {
  277. return FALSE;
  278. }
  279. }
  280. int pos = atoi(sFaceSize);
  281. if (iCmd == IDC_PLAINTEXT_SIZE)
  282. {
  283. SendDlgItemMessage(hDlg, IDC_FONTSIZE, TBM_SETPOS, TRUE, pos);
  284. }
  285. iHeight = pos; // Was for CSSAMP: MulDiv(pos, g_iLogPixelsY, 72);
  286. // Get facename
  287. i = SendDlgItemMessage(hDlg, idFont, CB_GETCURSEL, 0, 0);
  288. if (SendDlgItemMessage(hDlg, idFont, CB_GETLBTEXT, i, (LPARAM)sFaceName) == CB_ERR) {
  289. return FALSE;
  290. }
  291. SetStyle(
  292. iStyle,
  293. iHeight,
  294. IsDlgButtonChecked(hDlg, idBold) == BST_CHECKED ? 700 : 400,
  295. IsDlgButtonChecked(hDlg, idItalic) == BST_CHECKED,
  296. IsDlgButtonChecked(hDlg, idUnderline) == BST_CHECKED,
  297. IsDlgButtonChecked(hDlg, idStrikeout) == BST_CHECKED,
  298. sFaceName);
  299. InvalidateText();
  300. return TRUE;
  301. }
  302. // SplitTransform here temporarily for testing purposes
  303. void SplitTransform(
  304. const Matrix &matrix,
  305. PointF &scale,
  306. REAL &rotate,
  307. REAL &shear,
  308. PointF &translate)
  309. {
  310. REAL m[6];
  311. matrix.GetElements(m);
  312. // m11 = m[0] m12 = m[1]
  313. // m21 = m[2] m22 = m[3]
  314. // dx = m[4] dy = m[5]
  315. // Extract translation
  316. translate = PointF(m[4],m[5]);
  317. // 2 2
  318. // Use Sin theta + cos theta = 1 to obtain (absolute value) of
  319. // the X scale factor. Because we're returning the shear as an X
  320. // shear, it's a factor of y, so this formula is correct regardless of shear.
  321. REAL m11Sq = m[0]*m[0];
  322. REAL m12Sq = m[1]*m[1];
  323. scale.X = REAL(sqrt(m11Sq + m12Sq));
  324. // Always treat X scale factor as positive: handle originally negative
  325. // X scale factors as rotation by 180 degrees and invert Y scale factor.
  326. if (m[1] >= 0 && m[0] > 0)
  327. {
  328. rotate = REAL(atan(m[1]/m[0])); // 0-90
  329. }
  330. else if (m[0] < 0)
  331. {
  332. rotate = REAL(atan(m[1]/m[0]) + 3.14159265358979); // 90-270
  333. }
  334. else if (m[1] < 0 && m[0] > 0)
  335. {
  336. rotate = REAL(atan(m[1]/m[0]) + 2*3.14159265358979);// 270-360
  337. }
  338. else
  339. {
  340. // m[0] == 0
  341. if (m[1] > 0)
  342. {
  343. rotate = REAL(3.14159265358979); // 90
  344. }
  345. else
  346. {
  347. rotate = REAL(3*3.14159265358979/2); // 270
  348. }
  349. }
  350. // y scale factor in terms of x scale factor
  351. scale.Y = scale.X * (m[0]*m[3] - m[1]*m[2]) / (m11Sq + m12Sq);
  352. // Shear
  353. shear = (m[1]*m[3] + m[0]*m[2]) / (m11Sq + m[1]);
  354. }
  355. class TransformControl {
  356. public:
  357. void init(INT x, INT y, INT width, INT height, INT cellHeight) {
  358. rect.X = x;
  359. rect.Y = y;
  360. rect.Width = width;
  361. rect.Height = height;
  362. origin.X = x + width/2;
  363. origin.Y = y + height/2;
  364. fontCellHeight = cellHeight;
  365. }
  366. BOOL inControl(INT x, INT y, Point *point) {
  367. if ( x >= rect.X
  368. && y >= rect.Y
  369. && x < rect.X + rect.Width
  370. && y < rect.Y + rect.Height + fontCellHeight) {
  371. if (point)
  372. {
  373. // Set point to tenths of the controls 'radius'
  374. point->X = (x - origin.X) * 200 / rect.Width;
  375. point->Y = (y - origin.Y) * 200 / rect.Height;
  376. }
  377. return TRUE;
  378. }
  379. else
  380. {
  381. return FALSE;
  382. }
  383. }
  384. void paint(HDC hdc) {
  385. // Add vertical and horizontal lines
  386. HPEN hOldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 0, COLORREF(0x00C0C0C0)));
  387. MoveToEx(hdc, rect.X, origin.Y, NULL);
  388. LineTo (hdc, rect.X+rect.Width, origin.Y);
  389. MoveToEx(hdc, origin.X, rect.Y, NULL);
  390. LineTo (hdc, origin.X, rect.Y+rect.Height);
  391. DeleteObject(SelectObject(hdc, hOldPen));
  392. }
  393. Rect rect;
  394. Point origin;
  395. INT fontCellHeight;
  396. enum {
  397. SampleRectSize = 40
  398. };
  399. };
  400. class AngleTransformControl : TransformControl {
  401. public:
  402. void init(INT x, INT y, INT width, INT height, INT cellHeight) {
  403. TransformControl::init(x, y, width, height, cellHeight);
  404. angle = 0;
  405. }
  406. void mouse(INT x, INT y) {
  407. Point vector;
  408. if (inControl(x, y, &vector)) {
  409. if (vector.Y > 100)
  410. {
  411. // Reset
  412. angle = 0;
  413. }
  414. else if (vector.X == 0) // Convert mouse hit to angle
  415. {
  416. // Special case: straight up or straight down
  417. if (vector.Y < 0)
  418. {
  419. angle = REAL(3.14159265358979*3/2);
  420. }
  421. else if (vector.Y == 0)
  422. {
  423. angle = 0;
  424. }
  425. else
  426. {
  427. angle = REAL(3.14159265358979/2);
  428. }
  429. }
  430. else
  431. {
  432. angle = REAL(atan(REAL(vector.Y)/REAL(vector.X)));
  433. if (vector.X < 0)
  434. {
  435. angle += REAL(3.14159265358979);
  436. }
  437. }
  438. }
  439. }
  440. void paint(HDC hdc) {
  441. Ellipse(hdc, rect.X, rect.Y, rect.X+rect.Width, rect.Y+rect.Height);
  442. TransformControl::paint(hdc);
  443. MoveToEx(hdc, origin.X, origin.Y, NULL);
  444. Point vector;
  445. vector.X = INT(cos(angle)*80+0.4999);
  446. vector.Y = INT(sin(angle)*80+0.4999);
  447. LineTo(hdc, origin.X+vector.X*rect.Width/200, origin.Y+vector.Y*rect.Height/200);
  448. SetTextAlign(hdc, TA_CENTER);
  449. char strKey[50];
  450. INT strLen = sprintf(strKey, "Rotate %.1f", angle * 180 / 3.14159265358979);
  451. RECT textRect = {rect.X, rect.Y+rect.Height, rect.X+rect.Width, rect.Y+rect.Height+fontCellHeight};
  452. ExtTextOutA(hdc, origin.X, rect.Y+rect.Height, ETO_OPAQUE, &textRect, strKey, strLen, NULL);
  453. }
  454. REAL getAngle() {
  455. return REAL(angle * 180 / 3.14159265358979);
  456. }
  457. REAL angle;
  458. };
  459. class VectorTransformControl : public TransformControl {
  460. public:
  461. void init(INT x, INT y, INT width, INT height, INT cellHeight) {
  462. TransformControl::init(x, y, width, height, cellHeight);
  463. }
  464. void paint(HDC hdc) {
  465. Rectangle(hdc, rect.X, rect.Y, rect.X+rect.Width, rect.Y+rect.Height);
  466. TransformControl::paint(hdc);
  467. }
  468. Point vector;
  469. };
  470. class ScaleTransformControl : public VectorTransformControl {
  471. public:
  472. void init(INT x, INT y, INT width, INT height, INT cellHeight) {
  473. TransformControl::init(x, y, width, height, cellHeight);
  474. vector.X = SampleRectSize;
  475. vector.Y = SampleRectSize;
  476. }
  477. void mouse(INT x, INT y) {
  478. if (inControl(x, y, &vector)) {
  479. if (vector.Y > 100)
  480. { // Reset
  481. vector.X = SampleRectSize;
  482. vector.Y = SampleRectSize;
  483. }
  484. }
  485. }
  486. void paint(HDC hdc) {
  487. VectorTransformControl::paint(hdc);
  488. MoveToEx(hdc, origin.X, origin.Y, NULL);
  489. LineTo(hdc, origin.X+vector.X*rect.Width/200, origin.Y);
  490. LineTo(hdc, origin.X+vector.X*rect.Width/200, origin.Y+vector.Y*rect.Height/200);
  491. LineTo(hdc, origin.X, origin.Y+vector.Y*rect.Height/200);
  492. LineTo(hdc, origin.X, origin.Y);
  493. SetTextAlign(hdc, TA_CENTER);
  494. char strKey[50];
  495. INT strLen = sprintf(strKey, "Scale %.1f,%.1f", REAL(vector.X)/REAL(SampleRectSize), REAL(vector.Y)/REAL(SampleRectSize));
  496. RECT textRect = {rect.X, rect.Y+rect.Height, rect.X+rect.Width, rect.Y+rect.Height+fontCellHeight};
  497. ExtTextOutA(hdc, origin.X, rect.Y+rect.Height, ETO_OPAQUE, &textRect, strKey, strLen, NULL);
  498. }
  499. REAL getScaleX() {
  500. REAL ScaleX = REAL(vector.X)/REAL(SampleRectSize);
  501. // snap values close to 1.0 and -1.0 to make it easier to test mirror image
  502. if ((ScaleX > 0.9) && (ScaleX < 1.1))
  503. ScaleX = 1.0;
  504. if ((ScaleX < -0.9) && (ScaleX > -1.1))
  505. ScaleX = -1.0;
  506. return ScaleX;
  507. }
  508. REAL getScaleY() {
  509. REAL ScaleY = REAL(vector.Y)/REAL(SampleRectSize);
  510. // snap values close to 1.0 and -1.0 to make it easier to test mirror image
  511. if ((ScaleY > 0.9) && (ScaleY < 1.1))
  512. ScaleY = 1.0;
  513. if ((ScaleY < -0.9) && (ScaleY > -1.1))
  514. ScaleY = -1.0;
  515. return ScaleY;
  516. }
  517. };
  518. class ShearTransformControl : public VectorTransformControl {
  519. public:
  520. void init(INT x, INT y, INT width, INT height, INT cellHeight) {
  521. TransformControl::init(x, y, width, height, cellHeight);
  522. vector.X = 0;
  523. vector.Y = 0;
  524. }
  525. void mouse(INT x, INT y) {
  526. if (inControl(x, y, &vector)) {
  527. if (vector.Y > 100)
  528. { // Reset
  529. vector.X = 0;
  530. vector.Y = 0;
  531. }
  532. else
  533. { // Offset so user appears to be dragging 1,1 coordinate
  534. vector.X -= SampleRectSize;
  535. vector.Y -= SampleRectSize;
  536. }
  537. }
  538. }
  539. void paint(HDC hdc) {
  540. VectorTransformControl::paint(hdc);
  541. INT vx = vector.X*rect.Width/200;
  542. INT vy = vector.Y*rect.Height/200;
  543. MoveToEx(hdc, origin.X, origin.Y, NULL);
  544. LineTo(hdc, origin.X+vx, origin.Y+ rect.Height*SampleRectSize/200);
  545. LineTo(hdc, origin.X+vx+rect.Width*SampleRectSize/200, origin.Y+vy+rect.Height*SampleRectSize/200);
  546. LineTo(hdc, origin.X+ rect.Width*SampleRectSize/200, origin.Y+vy);
  547. LineTo(hdc, origin.X, origin.Y);
  548. SetTextAlign(hdc, TA_CENTER);
  549. char strKey[50];
  550. INT strLen = sprintf(strKey, "Shear %.1f,%.1f", REAL(vector.X)/REAL(SampleRectSize), REAL(vector.Y)/REAL(SampleRectSize));
  551. RECT textRect = {rect.X, rect.Y+rect.Height, rect.X+rect.Width, rect.Y+rect.Height+fontCellHeight};
  552. ExtTextOutA(hdc, origin.X, rect.Y+rect.Height, ETO_OPAQUE, &textRect, strKey, strLen, NULL);
  553. }
  554. REAL getShearX() {
  555. return REAL(vector.X)/REAL(SampleRectSize);
  556. }
  557. REAL getShearY() {
  558. return REAL(vector.Y)/REAL(SampleRectSize);
  559. }
  560. };
  561. class TranslateTransformControl : public VectorTransformControl {
  562. public:
  563. void init(INT x, INT y, INT width, INT height, INT cellHeight) {
  564. TransformControl::init(x, y, width, height, cellHeight);
  565. vector.X = 0;
  566. vector.Y = 0;
  567. }
  568. void mouse(INT x, INT y) {
  569. if (inControl(x, y, &vector)) {
  570. if (vector.Y > 100)
  571. { // Reset
  572. vector.X = 0;
  573. vector.Y = 0;
  574. }
  575. else
  576. { // Offset so user appears to be dragging 1,1 coordinate
  577. vector.X -= SampleRectSize;
  578. vector.Y -= SampleRectSize;
  579. }
  580. }
  581. }
  582. void paint(HDC hdc) {
  583. VectorTransformControl::paint(hdc);
  584. MoveToEx(hdc, origin.X+vector.X*rect.Width/200, origin.Y+vector.Y*rect.Height/200, NULL);
  585. LineTo (hdc, origin.X+(vector.X+SampleRectSize)*rect.Width/200, origin.Y+vector.Y*rect.Height/200);
  586. LineTo (hdc, origin.X+(vector.X+SampleRectSize)*rect.Width/200, origin.Y+(vector.Y+SampleRectSize)*rect.Height/200);
  587. LineTo (hdc, origin.X+vector.X*rect.Width/200, origin.Y+(vector.Y+SampleRectSize)*rect.Height/200);
  588. LineTo (hdc, origin.X+vector.X*rect.Width/200, origin.Y+vector.Y*rect.Height/200);
  589. SetTextAlign(hdc, TA_CENTER);
  590. char strKey[50];
  591. INT strLen = sprintf(strKey, "Trnslt %.1f,%.1f", REAL(vector.X)/REAL(SampleRectSize), REAL(vector.Y)/REAL(SampleRectSize));
  592. RECT textRect = {rect.X, rect.Y+rect.Height, rect.X+rect.Width, rect.Y+rect.Height+fontCellHeight};
  593. ExtTextOutA(hdc, origin.X, rect.Y+rect.Height, ETO_OPAQUE, &textRect, strKey, strLen, NULL);
  594. }
  595. REAL getTranslateX() {
  596. return REAL(vector.X)/REAL(SampleRectSize);
  597. }
  598. REAL getTranslateY() {
  599. return REAL(vector.Y)/REAL(SampleRectSize);
  600. }
  601. };
  602. class WorldTransformSetting {
  603. public:
  604. void init (HWND hDlg, Matrix *matrix);
  605. void paint (HWND hWnd);
  606. void CalculateMatrix();
  607. void leftButtonDown (HWND hWnd, INT x, INT y);
  608. void leftButtonUp (HWND hWnd, INT x, INT y);
  609. void mouseMove (HWND hWnd, INT x, INT y);
  610. static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  611. private:
  612. ScaleTransformControl scaleControl;
  613. AngleTransformControl rotateControl;
  614. ShearTransformControl shearControl;
  615. TranslateTransformControl translateControl;
  616. INT fontCellHeight;
  617. INT m11X, m11Y, m12X, m12Y, m21X, m21Y, m22X, m22Y, dxX, dxY, dyX, dyY;
  618. INT rX, rY, sxX, sxY, syX, syY, shX, shY;
  619. Matrix *TransformMatrix;
  620. // The controls sit in a grid:
  621. //
  622. // ************************
  623. // * *
  624. // * ****** ****** ****** *
  625. // * * * * * * * *
  626. // * *Scl * *Rot * *Shr * *
  627. // * * * * * * * *
  628. // * ****** ****** ****** *
  629. // * *
  630. // * ****** m11 m12 0 *
  631. // * * * *
  632. // * *xlt * m21 m22 0 *
  633. // * * * *
  634. // * ****** d1 d2 1 *
  635. // * *
  636. // ************************
  637. };
  638. void WorldTransformSetting::init(HWND hWnd, Matrix *matrix) {
  639. SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)this->WndProc);
  640. SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)this);
  641. TransformMatrix = matrix;
  642. RECT rect;
  643. GetClientRect(hWnd, &rect);
  644. fontCellHeight = rect.bottom*2/30;
  645. scaleControl.init (rect.right/34, rect.bottom/27, rect.right*10/34, rect.bottom*10/27, fontCellHeight);
  646. rotateControl.init (rect.right*12/34, rect.bottom/27, rect.right*10/34, rect.bottom*10/27, fontCellHeight);
  647. shearControl.init (rect.right*23/34, rect.bottom/27, rect.right*10/34, rect.bottom*10/27, fontCellHeight);
  648. translateControl.init(rect.right/34, rect.bottom*14/27, rect.right*10/34, rect.bottom*10/27, fontCellHeight);
  649. m11X = rect.right*17/34; m11Y = rect.bottom*14/27;
  650. m12X = rect.right*28/34; m12Y = rect.bottom*14/27;
  651. m21X = rect.right*17/34; m21Y = rect.bottom*17/27;
  652. m22X = rect.right*28/34; m22Y = rect.bottom*17/27;
  653. dxX = rect.right*17/34; dxY = rect.bottom*20/27;
  654. dyX = rect.right*28/34; dyY = rect.bottom*20/27;
  655. rX = rect.right*15/34; rY = rect.bottom*24/27;
  656. sxX = rect.right*20/34; sxY = rect.bottom*24/27;
  657. syX = rect.right*24/34; syY = rect.bottom*24/27;
  658. shX = rect.right*30/34; shY = rect.bottom*24/27;
  659. return;
  660. }
  661. void WorldTransformSetting::paint(HWND hWnd) {
  662. PAINTSTRUCT ps;
  663. HDC hdc = BeginPaint(hWnd, &ps);
  664. HFONT hOldFont = (HFONT) SelectObject(hdc, CreateFontA(fontCellHeight,0,0,0,400,0,0,0,0,0,0,0,0,"Tahoma"));
  665. SetBkColor(hdc, COLORREF(0xC0C0C0));
  666. scaleControl.paint(hdc);
  667. rotateControl.paint(hdc);
  668. shearControl.paint(hdc);
  669. translateControl.paint(hdc);
  670. // Write out the matrix
  671. REAL mv[6];
  672. g_WorldTransform.GetElements(mv);
  673. SetTextAlign(hdc, TA_CENTER);
  674. char strKey[50];
  675. RECT textRect = {m11X - (m12X-m11X)/2, m11Y, m12X+(m12X-m11X)/2, shY+fontCellHeight};
  676. ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &textRect, "", 0, NULL);
  677. INT strLen;
  678. strLen = sprintf(strKey, "m11 %.1f", mv[0]); TextOutA(hdc, m11X, m11Y, strKey, strLen);
  679. strLen = sprintf(strKey, "m12 %.1f", mv[1]); TextOutA(hdc, m12X, m12Y, strKey, strLen);
  680. strLen = sprintf(strKey, "m21 %.1f", mv[2]); TextOutA(hdc, m21X, m21Y, strKey, strLen);
  681. strLen = sprintf(strKey, "m22 %.1f", mv[3]); TextOutA(hdc, m22X, m22Y, strKey, strLen);
  682. strLen = sprintf(strKey, "dx %.1f", mv[4]); TextOutA(hdc, dxX, dxY, strKey, strLen);
  683. strLen = sprintf(strKey, "dy %.1f", mv[5]); TextOutA(hdc, dyX, dyY, strKey, strLen);
  684. // Show result of Split Transform
  685. PointF scale;
  686. REAL rotate;
  687. REAL shear;
  688. PointF translate;
  689. SplitTransform(g_WorldTransform, scale, rotate, shear, translate);
  690. rotate = REAL(rotate * 180 / 3.14159265358979);
  691. strLen = sprintf(strKey, "r %.1f", rotate); TextOutA(hdc, rX, rY, strKey, strLen);
  692. strLen = sprintf(strKey, "sx %.1f", scale.X); TextOutA(hdc, sxX, sxY, strKey, strLen);
  693. strLen = sprintf(strKey, "sy %.1f", scale.Y); TextOutA(hdc, syX, syY, strKey, strLen);
  694. strLen = sprintf(strKey, "sh %.1f", shear); TextOutA(hdc, shX, shY, strKey, strLen);
  695. DeleteObject(SelectObject(hdc, hOldFont));
  696. EndPaint(hWnd, &ps);
  697. InvalidateText();
  698. return;
  699. }
  700. void WorldTransformSetting::CalculateMatrix() {
  701. TransformMatrix->Reset();
  702. TransformMatrix->Rotate(rotateControl.getAngle());
  703. TransformMatrix->Scale(scaleControl.getScaleX(), scaleControl.getScaleY());
  704. TransformMatrix->Shear(shearControl.getShearX(), shearControl.getShearY());
  705. TransformMatrix->Translate(
  706. translateControl.getTranslateX() * 10, // * 10 (arbitrary) to make it visible
  707. translateControl.getTranslateY() * 10);
  708. return;
  709. }
  710. void WorldTransformSetting::leftButtonDown(HWND hWnd, INT x, INT y) {
  711. scaleControl.mouse(x,y);
  712. rotateControl.mouse(x,y);
  713. shearControl.mouse(x,y);
  714. translateControl.mouse(x,y);
  715. CalculateMatrix();
  716. InvalidateRect(hWnd, NULL, TRUE);
  717. return;
  718. }
  719. void WorldTransformSetting::leftButtonUp(HWND hWnd, INT x, INT y) {
  720. scaleControl.mouse(x,y);
  721. rotateControl.mouse(x,y);
  722. shearControl.mouse(x,y);
  723. translateControl.mouse(x,y);
  724. CalculateMatrix();
  725. InvalidateRect(hWnd, NULL, TRUE);
  726. return;
  727. }
  728. void WorldTransformSetting::mouseMove(HWND hWnd, INT x, INT y) {
  729. scaleControl.mouse(x,y);
  730. rotateControl.mouse(x,y);
  731. shearControl.mouse(x,y);
  732. translateControl.mouse(x,y);
  733. CalculateMatrix();
  734. InvalidateRect(hWnd, NULL, TRUE);
  735. return;
  736. }
  737. LRESULT CALLBACK WorldTransformSetting::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
  738. HDC hdc;
  739. WorldTransformSetting *thisSetting = (WorldTransformSetting*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
  740. switch (message) {
  741. case WM_LBUTTONDOWN:
  742. thisSetting->leftButtonDown(hWnd, LOWORD(lParam), HIWORD(lParam));
  743. break;
  744. case WM_MOUSEMOVE:
  745. // Treat movement like lbuttonup while lbutton is down,
  746. // so the selection tracks the cursor movement.
  747. if (wParam & MK_LBUTTON) {
  748. thisSetting->mouseMove(hWnd, LOWORD(lParam), HIWORD(lParam));
  749. }
  750. break;
  751. case WM_LBUTTONUP:
  752. thisSetting->leftButtonUp(hWnd, LOWORD(lParam), HIWORD(lParam));
  753. break;
  754. case WM_PAINT:
  755. thisSetting->paint(hWnd);
  756. break;
  757. default:
  758. return DefWindowProc(hWnd, message, wParam, lParam);
  759. }
  760. return 0;
  761. }
  762. WorldTransformSetting worldTransform;
  763. WorldTransformSetting fontTransform;
  764. WorldTransformSetting driverTransform;
  765. const char *szAlignments[] = {
  766. "AlignNear",
  767. "AlignCenter",
  768. "AlignFar"
  769. };
  770. const char *szUnits[] = {
  771. "UnitWorld", // 0 -- World coordinate (non-physical unit)
  772. "UnitNotValid", // 1 -- UnitDisplay not valid for size units -- device dependent
  773. "UnitPixel", // 2 -- Each unit is one device pixel.
  774. "UnitPoint", // 3 -- Each unit is a printer's point, or 1/72 inch.
  775. "UnitInch", // 4 -- Each unit is 1 inch.
  776. "UnitDocument", // 5 -- Each unit is 1/300 inch.
  777. "UnitMillimeter" // 6 -- Each unit is 1 millimeter.
  778. };
  779. const char *szForeGroundBrush[] = {
  780. "Solid",
  781. "RectGradient",
  782. "RadialGradient",
  783. "TriangleGradient",
  784. "LineGradient"
  785. };
  786. const char *szBackGroundBrush[] = {
  787. "Solid",
  788. "RectGradient",
  789. "RadialGradient",
  790. "TriangleGradient",
  791. "LineGradient"
  792. };
  793. const char *szTextMode[] = {
  794. "SystemDefault",
  795. "SingleBitPerPixelGridFit",
  796. "SingleBitPerPixel",
  797. "AntiAliasGridFit",
  798. "AntiAlias",
  799. "ClearTypeGridFit"
  800. };
  801. const char *szUniChar[] = {
  802. "(File)",
  803. "(Initial text)",
  804. "(Multilingual text)",
  805. "(Metrics text)",
  806. "200B ZWSP",
  807. "200C ZWNJ",
  808. "200D ZWJ",
  809. "200E LRM",
  810. "200F RLM",
  811. "202A LRE",
  812. "202B RLE",
  813. "202C PDF",
  814. "202D LRO",
  815. "202E RLO",
  816. "206A ISS",
  817. "206B ASS",
  818. "206E NADS",
  819. "206F NODS",
  820. "0908 Letter Ii",
  821. "0915 Letter Ka",
  822. "093f Vowel I",
  823. "094D Virama",
  824. };
  825. const char *szRows[] = {
  826. "1",
  827. "2",
  828. "4",
  829. "8",
  830. "16",
  831. "32",
  832. "64" // ! Let's hope our friendly client brought his or her magnifying glass ....
  833. };
  834. const char *szDigitSubstitute[] = {
  835. "StringDigitSubstituteUser",
  836. "StringDigitSubstituteNone",
  837. "StringDigitSubstituteNational",
  838. "StringDigitSubstituteTraditional"
  839. };
  840. // Keep in sync with szLanguage
  841. const LANGID Language[] = {
  842. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
  843. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  844. MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
  845. MAKELANGID(LANG_AFRIKAANS, SUBLANG_NEUTRAL),
  846. MAKELANGID(LANG_ALBANIAN, SUBLANG_NEUTRAL),
  847. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SAUDI_ARABIA),
  848. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_IRAQ),
  849. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_EGYPT),
  850. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_LIBYA),
  851. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_ALGERIA),
  852. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_MOROCCO),
  853. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_TUNISIA),
  854. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_OMAN),
  855. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_YEMEN),
  856. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SYRIA),
  857. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_JORDAN),
  858. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_LEBANON),
  859. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_KUWAIT),
  860. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_UAE),
  861. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_BAHRAIN),
  862. MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_QATAR),
  863. MAKELANGID(LANG_ARMENIAN,SUBLANG_NEUTRAL),
  864. MAKELANGID(LANG_ASSAMESE, SUBLANG_NEUTRAL),
  865. MAKELANGID(LANG_AZERI, SUBLANG_AZERI_LATIN),
  866. MAKELANGID(LANG_AZERI, SUBLANG_AZERI_CYRILLIC),
  867. MAKELANGID(LANG_BASQUE, SUBLANG_NEUTRAL),
  868. MAKELANGID(LANG_BELARUSIAN, SUBLANG_NEUTRAL),
  869. MAKELANGID(LANG_BENGALI, SUBLANG_NEUTRAL),
  870. MAKELANGID(LANG_BULGARIAN, SUBLANG_NEUTRAL),
  871. MAKELANGID(LANG_CATALAN, SUBLANG_NEUTRAL),
  872. MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL),
  873. MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),
  874. MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_HONGKONG),
  875. MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SINGAPORE),
  876. MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_MACAU),
  877. MAKELANGID(LANG_CROATIAN,SUBLANG_NEUTRAL),
  878. MAKELANGID(LANG_CZECH, SUBLANG_NEUTRAL),
  879. MAKELANGID(LANG_DANISH, SUBLANG_NEUTRAL),
  880. MAKELANGID(LANG_DUTCH, SUBLANG_DUTCH),
  881. MAKELANGID(LANG_DUTCH, SUBLANG_DUTCH_BELGIAN),
  882. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
  883. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK),
  884. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_AUS),
  885. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_CAN),
  886. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_NZ),
  887. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_EIRE),
  888. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_SOUTH_AFRICA),
  889. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_JAMAICA),
  890. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_CARIBBEAN),
  891. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_BELIZE),
  892. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_TRINIDAD),
  893. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_ZIMBABWE),
  894. MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_PHILIPPINES),
  895. MAKELANGID(LANG_ESTONIAN,SUBLANG_NEUTRAL),
  896. MAKELANGID(LANG_FAEROESE, SUBLANG_NEUTRAL),
  897. MAKELANGID(LANG_FARSI, SUBLANG_NEUTRAL),
  898. MAKELANGID(LANG_FINNISH, SUBLANG_NEUTRAL),
  899. MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH),
  900. MAKELANGID(LANG_FRENCH, ,SUBLANG_FRENCH_BELGIAN),
  901. MAKELANGID(LANG_FRENCH, ,SUBLANG_FRENCH_CANADIAN),
  902. MAKELANGID(LANG_FRENCH, ,SUBLANG_FRENCH_SWISS),
  903. MAKELANGID(LANG_FRENCH, ,SUBLANG_FRENCH_LUXEMBOURG),
  904. MAKELANGID(LANG_FRENCH, ,SUBLANG_FRENCH_MONACO),
  905. MAKELANGID(LANG_GEORGIAN,SUBLANG_NEUTRAL),
  906. MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN),
  907. MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_SWISS),
  908. MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN),
  909. MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_LUXEMBOURG),
  910. MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_LIECHTENSTEIN),
  911. MAKELANGID(LANG_GREEK, SUBLANG_NEUTRAL),
  912. MAKELANGID(LANG_GUJARATI,SUBLANG_NEUTRAL),
  913. MAKELANGID(LANG_HEBREW, SUBLANG_NEUTRAL),
  914. MAKELANGID(LANG_HINDI, SUBLANG_NEUTRAL),
  915. MAKELANGID(LANG_HUNGARIAN, SUBLANG_NEUTRAL),
  916. MAKELANGID(LANG_ICELANDIC, SUBLANG_NEUTRAL),
  917. MAKELANGID(LANG_INDONESIAN, SUBLANG_NEUTRAL),
  918. MAKELANGID(LANG_ITALIAN,SUBLANG_ITALIAN),
  919. MAKELANGID(LANG_ITALIAN,SUBLANG_ITALIAN_SWISS),
  920. MAKELANGID(LANG_JAPANESE, SUBLANG_NEUTRAL),
  921. MAKELANGID(LANG_KANNADA, SUBLANG_NEUTRAL),
  922. MAKELANGID(LANG_KASHMIRI, SUBLANG_KASHMIRI_SASIA),
  923. MAKELANGID(LANG_KAZAK, SUBLANG_NEUTRAL),
  924. MAKELANGID(LANG_KONKANI, SUBLANG_NEUTRAL),
  925. MAKELANGID(LANG_KOREAN,SUBLANG_KOREAN),
  926. MAKELANGID(LANG_LATVIAN,SUBLANG_NEUTRAL),
  927. MAKELANGID(LANG_LITHUANIAN,SUBLANG_LITHUANIAN),
  928. MAKELANGID(LANG_MACEDONIAN,SUBLANG_NEUTRAL),
  929. MAKELANGID(LANG_MALAY, SUBLANG_MALAY_MALAYSIA),
  930. MAKELANGID(LANG_MALAY, SUBLANG_MALAY_BRUNEI_DARUSSALAM),
  931. MAKELANGID(LANG_MALAYALAM,SUBLANG_NEUTRAL),
  932. MAKELANGID(LANG_MANIPURI,SUBLANG_NEUTRAL),
  933. MAKELANGID(LANG_MARATHI,SUBLANG_NEUTRAL),
  934. MAKELANGID(LANG_NEPALI, SUBLANG_NEPALI_INDIA),
  935. MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL),
  936. MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK),
  937. MAKELANGID(LANG_ORIYA, SUBLANG_NEUTRAL),
  938. MAKELANGID(LANG_POLISH, SUBLANG_NEUTRAL),
  939. MAKELANGID(LANG_PORTUGUESE, SUBLANG_PORTUGUESE),
  940. MAKELANGID(LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN),
  941. MAKELANGID(LANG_PUNJABI, SUBLANG_NEUTRAL),
  942. MAKELANGID(LANG_ROMANIAN, SUBLANG_NEUTRAL),
  943. MAKELANGID(LANG_RUSSIAN, SUBLANG_NEUTRAL),
  944. MAKELANGID(LANG_SANSKRIT, SUBLANG_NEUTRAL),
  945. MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_LATIN),
  946. MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC),
  947. MAKELANGID(LANG_SINDHI, SUBLANG_NEUTRAL),
  948. MAKELANGID(LANG_SLOVAK, SUBLANG_NEUTRAL),
  949. MAKELANGID(LANG_SLOVENIAN, SUBLANG_NEUTRAL),
  950. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH),
  951. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MEXICAN),
  952. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN),
  953. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_GUATEMALA),
  954. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_COSTA_RICA),
  955. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_PANAMA),
  956. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_DOMINICAN_REPUBLIC),
  957. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_VENEZUELA),
  958. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_COLOMBIA),
  959. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_PERU),
  960. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_ARGENTINA),
  961. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_ECUADOR),
  962. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_CHILE),
  963. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_URUGUAY),
  964. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_PARAGUAY),
  965. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_BOLIVIA),
  966. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_EL_SALVADOR),
  967. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_HONDURAS),
  968. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_NICARAGUA),
  969. MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_PUERTO_RICO),
  970. MAKELANGID(LANG_SWAHILI,SUBLANG_NEUTRAL),
  971. MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH),
  972. MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH_FINLAND),
  973. MAKELANGID(LANG_TAMIL,SUBLANG_NEUTRAL),
  974. MAKELANGID(LANG_TATAR, SUBLANG_NEUTRAL),
  975. MAKELANGID(LANG_TELUGU, SUBLANG_NEUTRAL),
  976. MAKELANGID(LANG_THAI, SUBLANG_NEUTRAL),
  977. MAKELANGID(LANG_TURKISH,SUBLANG_NEUTRAL),
  978. MAKELANGID(LANG_UKRAINIAN, SUBLANG_NEUTRAL),
  979. MAKELANGID(LANG_URDU, SUBLANG_URDU_PAKISTAN),
  980. MAKELANGID(LANG_URDU, SUBLANG_URDU_INDIA),
  981. MAKELANGID(LANG_UZBEK, SUBLANG_UZBEK_LATIN),
  982. MAKELANGID(LANG_UZBEK, SUBLANG_UZBEK_CYRILLIC),
  983. MAKELANGID(LANG_VIETNAMESE, SUBLANG_NEUTRAL)
  984. };
  985. const char *szLanguage[] = {
  986. "Neutral, Neutral",
  987. "Neutral, Default",
  988. "Neutral, System default",
  989. "Afrikaans",
  990. "Albanian",
  991. "Arabic, Saudi Arabia",
  992. "Arabic, Iraq",
  993. "Arabic, Egypt",
  994. "Arabic, Libya",
  995. "Arabic, Algeria",
  996. "Arabic, Morocco",
  997. "Arabic, Tunisia",
  998. "Arabic, Oman",
  999. "Arabic, Yemen",
  1000. "Arabic, Syria",
  1001. "Arabic, Jordan",
  1002. "Arabic, Lebanon",
  1003. "Arabic, Kuwait",
  1004. "Arabic, UAE",
  1005. "Arabic, Bahrain",
  1006. "Arabic, Qatar",
  1007. "Armenian",
  1008. "Assamese",
  1009. "Azeri, Latin",
  1010. "Azeri, Cyrillic",
  1011. "Basque, ",
  1012. "Belarusian",
  1013. "Bengali",
  1014. "Bulgarian",
  1015. "Catalan",
  1016. "Chinese, Traditional",
  1017. "Chinese, Simplified",
  1018. "Chinese, Hong Kong",
  1019. "Chinese, Singapore",
  1020. "Chinese, Macau",
  1021. "Croatian",
  1022. "Czech",
  1023. "Danish",
  1024. "Dutch",
  1025. "Dutch, Belgian",
  1026. "English, US",
  1027. "English, UK",
  1028. "English, Australia",
  1029. "English, Canada",
  1030. "English, New Zeland",
  1031. "English, Eire",
  1032. "English, South Africa",
  1033. "English, Jamaica",
  1034. "English, Caribbean",
  1035. "English, Belize",
  1036. "English, Trinidad",
  1037. "English, Zimbabwe",
  1038. "English, Philippines",
  1039. "Estonian",
  1040. "Faeroese",
  1041. "Farsi",
  1042. "Finnish",
  1043. "French",
  1044. "French, Belgian",
  1045. "French, Canadian",
  1046. "French, Swiss",
  1047. "French, Luxembourg",
  1048. "French, Monaco",
  1049. "Georgian",
  1050. "German",
  1051. "German, Swiss",
  1052. "German, Austrian",
  1053. "German, Luxembourg",
  1054. "German, Liechtenstein",
  1055. "Greek",
  1056. "Gujarati",
  1057. "Hebrew",
  1058. "Hindi",
  1059. "Hungarian",
  1060. "Icelandic",
  1061. "Indonesian",
  1062. "Italian",
  1063. "Italian, Swiss",
  1064. "Japanese",
  1065. "Kannada",
  1066. "Kashmiri",
  1067. "Kazak",
  1068. "Konkani",
  1069. "Korean",
  1070. "Latvian",
  1071. "Lithuanian",
  1072. "FYRO Macedonian",
  1073. "Malay, Malaysia",
  1074. "MALAY, Brunei darussalam",
  1075. "Malayalam",
  1076. "Manipuri",
  1077. "Marathi",
  1078. "Nepali, India",
  1079. "Norwegian, Bokmal",
  1080. "Norwegian, Nynorsk",
  1081. "Oriya",
  1082. "Polish",
  1083. "Portuguese",
  1084. "Portuguese, Brazilian",
  1085. "Punjabi",
  1086. "Romanian",
  1087. "Russian",
  1088. "Sanskrit",
  1089. "Serbian, Latin",
  1090. "Serbian, Cyrillic",
  1091. "Sindhi",
  1092. "Slovak",
  1093. "Slovenian",
  1094. "Spanish",
  1095. "Spanish, Mexican",
  1096. "Spanish, Modern",
  1097. "Spanish, Guatemala",
  1098. "Spanish, Costa Rica",
  1099. "Spanish, Panama",
  1100. "Spanish, Dominican Republic",
  1101. "Spanish, Venezuela",
  1102. "Spanish, Colombia",
  1103. "Spanish, Peru",
  1104. "Spanish, Argentina",
  1105. "Spanish, Ecuador",
  1106. "Spanish, Chile",
  1107. "Spanish, Uruguay",
  1108. "Spanish, Paraguay",
  1109. "Spanish, Bolivia",
  1110. "Spanish, El Salvador",
  1111. "Spanish, Honduras",
  1112. "Spanish, Nicaragua",
  1113. "Spanish, Puerto Rico",
  1114. "Swahili",
  1115. "Swedish",
  1116. "Swedish, Finland",
  1117. "Tamil",
  1118. "Tatar",
  1119. "Telugu",
  1120. "Thai",
  1121. "Turkish",
  1122. "Ukrainian",
  1123. "Urdu, Pakistan",
  1124. "Urdu, India",
  1125. "Uzbek, Latin",
  1126. "Uzbek, Cyrillic",
  1127. "Vietnamese"
  1128. };
  1129. const char *szDriverDx[] = {
  1130. "0",
  1131. "10",
  1132. "15",
  1133. "20",
  1134. "25",
  1135. "30",
  1136. "35",
  1137. "40"
  1138. };
  1139. const char *szDriverPixels[] = {
  1140. "8",
  1141. "9",
  1142. "10",
  1143. "11",
  1144. "12",
  1145. "13",
  1146. "14",
  1147. "16",
  1148. "18",
  1149. "20",
  1150. "24",
  1151. "28",
  1152. "36"
  1153. };
  1154. const char *szOffsets[] = {
  1155. "0",
  1156. "100",
  1157. "200",
  1158. "300",
  1159. "400",
  1160. "500",
  1161. "600",
  1162. "700",
  1163. "800",
  1164. "900",
  1165. "a00",
  1166. "b00",
  1167. "c00",
  1168. "d00",
  1169. "e00",
  1170. "f00",
  1171. "1000",
  1172. "2000",
  1173. "3000",
  1174. "4000",
  1175. "5000",
  1176. "6000",
  1177. "7000",
  1178. "8000",
  1179. "9000",
  1180. "a000",
  1181. "b000",
  1182. "c000",
  1183. "d000",
  1184. "e000",
  1185. "f000",
  1186. };
  1187. void ShowSecondaryDialog(HWND hDialog)
  1188. {
  1189. RECT rcText; GetWindowRect(g_hTextWnd, &rcText);
  1190. RECT rcDialog; GetWindowRect(hDialog, &rcDialog);
  1191. if (rcText.bottom < rcDialog.bottom)
  1192. {
  1193. SetWindowPos(
  1194. g_hTextWnd,
  1195. NULL,
  1196. 0,0,
  1197. g_iMinWidth * 29 / 10, rcDialog.bottom - rcText.top,
  1198. SWP_NOZORDER | SWP_NOMOVE);
  1199. }
  1200. ShowWindow(hDialog, SW_SHOW);
  1201. }
  1202. void EnableSecondaryDialog(HWND hDlg, INT dialogId, BOOL enable)
  1203. {
  1204. if (g_ShowDriver)
  1205. {
  1206. g_ShowDriver = FALSE;
  1207. ShowWindow(g_hDriverSettingsDlg, SW_HIDE);
  1208. SendDlgItemMessage(hDlg, IDC_SHOWDRIVER, BM_SETCHECK, BST_UNCHECKED, 0);
  1209. }
  1210. if (g_ShowGlyphs)
  1211. {
  1212. g_ShowGlyphs = FALSE;
  1213. ShowWindow(g_hGlyphSettingsDlg, SW_HIDE);
  1214. SendDlgItemMessage(hDlg, IDC_SHOWGLYPHS, BM_SETCHECK, BST_UNCHECKED, 0);
  1215. }
  1216. if (enable)
  1217. {
  1218. switch (dialogId)
  1219. {
  1220. case IDC_SHOWGLYPHS: ShowSecondaryDialog(g_hGlyphSettingsDlg); g_ShowGlyphs = TRUE; break;
  1221. case IDC_SHOWDRIVER: ShowSecondaryDialog(g_hDriverSettingsDlg); g_ShowDriver = TRUE; break;
  1222. }
  1223. }
  1224. InvalidateText();
  1225. }
  1226. BOOL FormatFlag(HWND hDlg, INT iCmd, INT flag)
  1227. {
  1228. if (IsDlgButtonChecked(hDlg, iCmd))
  1229. {
  1230. g_formatFlags |= flag;
  1231. }
  1232. else
  1233. {
  1234. g_formatFlags &= ~flag;
  1235. }
  1236. SetFocus(g_hTextWnd);
  1237. InvalidateText();
  1238. return TRUE;
  1239. }
  1240. static COLORREF s_Colors[16];
  1241. void InsertText(HWND hDlg, char *textId)
  1242. {
  1243. BOOL fLoadTextFile = false;
  1244. char szTextFilename[MAX_PATH];
  1245. if (lstrcmpiA(textId, "(file)") == 0)
  1246. {
  1247. OPENFILENAMEA ofn = {0};
  1248. char szSelectedFile[128];
  1249. szSelectedFile[0] = 0;
  1250. ofn.lStructSize = sizeof(OPENFILENAME);
  1251. ofn.hwndOwner = hDlg;
  1252. ofn.lpstrFilter = "Text files\0*.TXT\0";
  1253. ofn.lpstrFile = szSelectedFile;
  1254. ofn.nMaxFile = sizeof(szSelectedFile);
  1255. ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES;
  1256. if (GetOpenFileNameA(&ofn))
  1257. {
  1258. fLoadTextFile = true;
  1259. lstrcpyA(szTextFilename, ofn.lpstrFile);
  1260. }
  1261. }
  1262. else if (lstrcmpiA(textId, "(Initial text)") == 0)
  1263. {
  1264. InitText(ID_INITIAL_TEXT);
  1265. InvalidateText();
  1266. }
  1267. else if (lstrcmpiA(textId, "(Multilingual text)") == 0)
  1268. {
  1269. InitText(ID_MULTILINGUAL_TEXT);
  1270. InvalidateText();
  1271. }
  1272. else if (lstrcmpiA(textId, "(Metrics text)") == 0)
  1273. {
  1274. InitText(ID_METRICS_TEXT);
  1275. InvalidateText();
  1276. }
  1277. else
  1278. {
  1279. // Attempt to load this as a file...
  1280. lstrcpyA(szTextFilename, textId);
  1281. fLoadTextFile = true;
  1282. }
  1283. if (fLoadTextFile)
  1284. {
  1285. HANDLE hf = CreateFileA (szTextFilename,
  1286. GENERIC_READ,
  1287. FILE_SHARE_READ,
  1288. NULL,
  1289. OPEN_EXISTING,
  1290. NULL,
  1291. NULL);
  1292. if (hf != INVALID_HANDLE_VALUE)
  1293. {
  1294. DWORD charRead;
  1295. BYTE *fileData = NULL;
  1296. DWORD fileSize = GetFileSize (hf, NULL);
  1297. if (fileSize > 0)
  1298. fileData = new BYTE [fileSize];
  1299. if (fileData)
  1300. {
  1301. if (ReadFile (hf,
  1302. fileData,
  1303. (DWORD)(min (MAX_TEXT * sizeof(WCHAR), fileSize)),
  1304. &charRead,
  1305. NULL) != 0)
  1306. {
  1307. INT c = 0;
  1308. if (((WCHAR *)fileData)[0] == 0xfeff)
  1309. {
  1310. charRead /= sizeof(WCHAR);
  1311. c += 1; // strip out Unicode BOM
  1312. }
  1313. TextDelete (0, g_iTextLen);
  1314. TextInsert (0, &((WCHAR *)fileData)[c], charRead - c);
  1315. InvalidateText();
  1316. }
  1317. delete [] fileData;
  1318. }
  1319. CloseHandle (hf);
  1320. }
  1321. }
  1322. }
  1323. BOOL Command(HWND hDlg, int iCmd, int iNotify, HWND hItemWnd) {
  1324. char str[100];
  1325. WCHAR wc;
  1326. int i;
  1327. char hex[] = "0123456789abcdef";
  1328. switch(iCmd) {
  1329. // Font family enumeration
  1330. case IDC_SHOWFAMILIES:
  1331. g_ShowFamilies = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1332. InvalidateText();
  1333. return TRUE;
  1334. case IDC_PLAINTEXT_FONT:
  1335. case IDC_PLAINTEXT_SIZE:
  1336. case IDC_PLAINTEXT_BOLD:
  1337. case IDC_PLAINTEXT_ITALIC:
  1338. case IDC_PLAINTEXT_UNDERLINE:
  1339. case IDC_PLAINTEXT_STRIKEOUT:
  1340. ChangeFont(
  1341. hDlg,
  1342. 0,
  1343. IDC_PLAINTEXT_FONT,
  1344. IDC_PLAINTEXT_SIZE,
  1345. IDC_PLAINTEXT_BOLD,
  1346. IDC_PLAINTEXT_ITALIC,
  1347. IDC_PLAINTEXT_UNDERLINE,
  1348. IDC_PLAINTEXT_STRIKEOUT,
  1349. iCmd,
  1350. iNotify);
  1351. return TRUE;
  1352. // Logical Unicode text
  1353. case IDC_LOGICAL:
  1354. g_ShowLogical = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1355. InvalidateText();
  1356. return TRUE;
  1357. case IDC_INSERT_CODEPOINT:
  1358. if (GetDlgItemTextA(hDlg, IDC_CODEPOINT, str, sizeof(str)))
  1359. {
  1360. if (str[0] == '(')
  1361. {
  1362. InsertText(hDlg, str);
  1363. }
  1364. else
  1365. {
  1366. wc = (WCHAR)HexToInt(str);
  1367. if (TextInsert(g_iCurChar, &wc, 1)) {
  1368. g_iCurChar++;
  1369. InvalidateText();
  1370. }
  1371. }
  1372. }
  1373. return TRUE;
  1374. case IDC_SHOWLEVELS:
  1375. g_fShowLevels = !g_fShowLevels;
  1376. if (g_fShowLevels)
  1377. {
  1378. SetDlgItemTextA(hDlg, IDC_SHOWLEVELS, "Hide levels");
  1379. }
  1380. else
  1381. {
  1382. SetDlgItemTextA(hDlg, IDC_SHOWLEVELS, "Show levels");
  1383. }
  1384. SetFocus(g_hTextWnd);
  1385. InvalidateText();
  1386. return TRUE;
  1387. // Glyph chart using DrawGlyphs
  1388. case IDC_SHOWGLYPHS:
  1389. EnableSecondaryDialog(hDlg, iCmd, IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED);
  1390. return TRUE;
  1391. // Driver strings
  1392. case IDC_SHOWDRIVER:
  1393. EnableSecondaryDialog(hDlg, iCmd, IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED);
  1394. return TRUE;
  1395. // Plain text displayed with DrawString
  1396. case IDC_SHOWDRAWSTRING:
  1397. g_ShowDrawString = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1398. InvalidateText();
  1399. return TRUE;
  1400. case IDC_SHOWGDI:
  1401. g_ShowGDI = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1402. InvalidateText();
  1403. return TRUE;
  1404. case IDC_METAFILE:
  1405. g_testMetafile = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1406. SetFocus(g_hTextWnd);
  1407. InvalidateText();
  1408. return TRUE;
  1409. // StringFormatFlags
  1410. case IDC_DIR: return FormatFlag(hDlg, iCmd, StringFormatFlagsDirectionRightToLeft);
  1411. case IDC_HORIZ: return FormatFlag(hDlg, iCmd, StringFormatFlagsDirectionVertical);
  1412. case IDC_NOFITBB: return FormatFlag(hDlg, iCmd, StringFormatFlagsNoFitBlackBox);
  1413. case IDC_DISPLAYFMT: return FormatFlag(hDlg, iCmd, StringFormatFlagsDisplayFormatControl);
  1414. case IDC_NOFALLBACK: return FormatFlag(hDlg, iCmd, StringFormatFlagsNoFontFallback);
  1415. case IDC_MEASPACE: return FormatFlag(hDlg, iCmd, StringFormatFlagsMeasureTrailingSpaces);
  1416. case IDC_NOWRAP: return FormatFlag(hDlg, iCmd, StringFormatFlagsNoWrap);
  1417. case IDC_LINELIMIT: return FormatFlag(hDlg, iCmd, StringFormatFlagsLineLimit);
  1418. case IDC_NOCLIP: return FormatFlag(hDlg, iCmd, StringFormatFlagsNoClip);
  1419. // Private, testing, flags
  1420. case IDC_NOGDI: return FormatFlag(hDlg, iCmd, 0x80000000);
  1421. case IDC_FULLIMAGER: return FormatFlag(hDlg, iCmd, 0x40000000);
  1422. case IDC_NOMINAL: return FormatFlag(hDlg, iCmd, 0x20000000);
  1423. // String format fields
  1424. case IDC_ALIGNNEAR: g_align = StringAlignmentNear; InvalidateText(); return TRUE;
  1425. case IDC_ALIGNCENTER: g_align = StringAlignmentCenter; InvalidateText(); return TRUE;
  1426. case IDC_ALIGNFAR: g_align = StringAlignmentFar; InvalidateText(); return TRUE;
  1427. case IDC_LINEALIGNNEAR: g_lineAlign = StringAlignmentNear; InvalidateText(); return TRUE;
  1428. case IDC_LINEALIGNCENTER: g_lineAlign = StringAlignmentCenter; InvalidateText(); return TRUE;
  1429. case IDC_LINEALIGNFAR: g_lineAlign = StringAlignmentFar; InvalidateText(); return TRUE;
  1430. case IDC_HOTKEYNONE: g_hotkey = HotkeyPrefixNone; InvalidateText(); return TRUE;
  1431. case IDC_HOTKEYSHOW: g_hotkey = HotkeyPrefixShow; InvalidateText(); return TRUE;
  1432. case IDC_HOTKEYHIDE: g_hotkey = HotkeyPrefixHide; InvalidateText(); return TRUE;
  1433. case IDC_TRIMMINGNONE: g_lineTrim = StringTrimmingNone; InvalidateText(); return TRUE;
  1434. case IDC_TRIMMINGCHAR: g_lineTrim = StringTrimmingCharacter; InvalidateText(); return TRUE;
  1435. case IDC_TRIMMINGWORD: g_lineTrim = StringTrimmingWord; InvalidateText(); return TRUE;
  1436. case IDC_TRIMMINGELPSCH: g_lineTrim = StringTrimmingEllipsisCharacter; InvalidateText(); return TRUE;
  1437. case IDC_TRIMMINGELPSWD: g_lineTrim = StringTrimmingEllipsisWord; InvalidateText(); return TRUE;
  1438. case IDC_TRIMMINGELPSURL: g_lineTrim = StringTrimmingEllipsisPath; InvalidateText(); return TRUE;
  1439. case IDC_DEFAULTFORMAT:
  1440. g_typographic = FALSE;
  1441. InvalidateText();
  1442. return TRUE;
  1443. case IDC_TYPOGRAPHICFORMAT:
  1444. g_typographic = TRUE;
  1445. InvalidateText();
  1446. return TRUE;
  1447. case IDC_FONTUNIT:
  1448. g_fontUnit = Unit(SendDlgItemMessage(hDlg, iCmd, CB_GETCURSEL, 0, 0));
  1449. InvalidateText();
  1450. return TRUE;
  1451. case IDC_FOREBRUSHTYPE:
  1452. GetTextForeGroundBrush(SendDlgItemMessage(hDlg, iCmd, CB_GETCURSEL, 0, 0));
  1453. InvalidateText();
  1454. return TRUE;
  1455. case IDC_BACKBRUSHTYPE:
  1456. GetTextBackGroundBrush(SendDlgItemMessage(hDlg, iCmd, CB_GETCURSEL, 0, 0));
  1457. InvalidateText();
  1458. return TRUE;
  1459. case IDC_TEXTMODE:
  1460. GetTextRenderingMode(SendDlgItemMessage(hDlg, iCmd, CB_GETCURSEL, 0, 0));
  1461. InvalidateText();
  1462. return TRUE;
  1463. // String formant digit substitution
  1464. case IDC_DIGIT_SUBSTITUTE:
  1465. GetDigitSubstituteMode(hDlg, SendDlgItemMessage(hDlg, iCmd, CB_GETCURSEL, 0, 0));
  1466. InvalidateText();
  1467. return TRUE;
  1468. case IDC_LANGUAGE:
  1469. g_Language = Language[SendDlgItemMessage(hDlg, iCmd, CB_GETCURSEL, 0, 0)];
  1470. InvalidateText();
  1471. return TRUE;
  1472. // Plain text displayed with paths
  1473. case IDC_SHOWPATH:
  1474. g_ShowPath = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1475. InvalidateText();
  1476. return TRUE;
  1477. // Font metrics
  1478. case IDC_SHOWMETRIC:
  1479. g_ShowMetric = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1480. InvalidateText();
  1481. return TRUE;
  1482. // Performance tests
  1483. case IDC_PERFORMANCE:
  1484. g_ShowPerformance = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1485. InvalidateText();
  1486. return TRUE;
  1487. // Scaling
  1488. case IDC_SHOWSCALING:
  1489. g_ShowScaling = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1490. InvalidateText();
  1491. return TRUE;
  1492. // Print
  1493. case IDC_PRINT:
  1494. PrintPage();
  1495. return TRUE;
  1496. case IDC_CLR_FOR:
  1497. {
  1498. CHOOSECOLOR cc = {0};
  1499. Color color(g_TextColor);
  1500. cc.lStructSize = sizeof cc;
  1501. cc.lpCustColors = s_Colors;
  1502. cc.rgbResult = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
  1503. cc.Flags = CC_RGBINIT | CC_ANYCOLOR;
  1504. BOOL bRet = ChooseColor(&cc);
  1505. color.SetFromCOLORREF(cc.rgbResult);
  1506. g_TextColor = color.GetValue();
  1507. GetTextForeGroundBrush(SendDlgItemMessage(hDlg, IDC_FOREBRUSHTYPE, CB_GETCURSEL, 0, 0));
  1508. InvalidateText();
  1509. }
  1510. return TRUE;
  1511. case IDC_CLR_BAC:
  1512. {
  1513. CHOOSECOLOR cc = {0};
  1514. Color color(g_BackColor);
  1515. cc.lStructSize = sizeof cc;
  1516. cc.lpCustColors = s_Colors;
  1517. cc.rgbResult = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());
  1518. cc.Flags = CC_RGBINIT | CC_ANYCOLOR;
  1519. BOOL bRet = ChooseColor(&cc);
  1520. color.SetFromCOLORREF(cc.rgbResult);
  1521. g_BackColor = color.GetValue();
  1522. GetTextBackGroundBrush(SendDlgItemMessage(hDlg, IDC_BACKBRUSHTYPE, CB_GETCURSEL, 0, 0));
  1523. InvalidateText();
  1524. }
  1525. return TRUE;
  1526. /* obsolete
  1527. case IDC_PLAINTEXT:
  1528. g_fShowPlainText = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1529. InvalidateText();
  1530. return TRUE;
  1531. case IDC_LANGUAGE:
  1532. if (iNotify == CBN_SELCHANGE) {
  1533. i = SendMessage(hItemWnd, CB_GETCURSEL, 0, 0);
  1534. if (SendMessage(hItemWnd, CB_GETLBTEXT, i, (LPARAM)str) != CB_ERR) {
  1535. wc = (WCHAR)HexToInt(str);
  1536. g_ScriptControl.uDefaultLanguage = wc;
  1537. InvalidateText();
  1538. }
  1539. } else if (iNotify == CBN_EDITCHANGE) {
  1540. if (SendMessage(hItemWnd, WM_GETTEXT, sizeof(str), (LPARAM)str)) {
  1541. wc = (WCHAR)HexToInt(str);
  1542. g_ScriptControl.uDefaultLanguage = wc;
  1543. InvalidateText();
  1544. }
  1545. }
  1546. return TRUE;
  1547. case IDC_HIGHLIGHT_FROM:
  1548. case IDC_HIGHLIGHT_TO:
  1549. InvalidateText();
  1550. return TRUE;
  1551. case IDC_LINEFILL:
  1552. g_fFillLines = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1553. InvalidateText();
  1554. return TRUE;
  1555. case IDC_LTR:
  1556. g_ScriptState.uBidiLevel = 0;
  1557. SendDlgItemMessage(hDlg, IDC_LTR, BM_SETSTATE, TRUE, 0);
  1558. SendDlgItemMessage(hDlg, IDC_RTL, BM_SETSTATE, FALSE, 0);
  1559. InvalidateText();
  1560. return TRUE;
  1561. case IDC_RTL:
  1562. g_ScriptState.uBidiLevel = 1;
  1563. SendDlgItemMessage(hDlg, IDC_RTL, BM_SETSTATE, TRUE, 0);
  1564. SendDlgItemMessage(hDlg, IDC_LTR, BM_SETSTATE, FALSE, 0);
  1565. InvalidateText();
  1566. return TRUE;
  1567. case IDC_CONTROL_CONTEXT:
  1568. g_ScriptControl.fContextDigits = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1569. InvalidateText();
  1570. return TRUE;
  1571. case IDC_DIGIT_SUBSTITUTE:
  1572. g_ScriptState.fDigitSubstitute = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1573. InvalidateText();
  1574. return TRUE;
  1575. case IDC_ARANUMCONTEXT:
  1576. g_ScriptState.fArabicNumContext = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1577. InvalidateText();
  1578. return TRUE;
  1579. case IDC_LEGACY_BIDI:
  1580. g_ScriptControl.fLegacyBidiClass = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1581. InvalidateText();
  1582. return TRUE;
  1583. case IDC_OVERRIDE:
  1584. g_ScriptState.fOverrideDirection = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1585. InvalidateText();
  1586. return TRUE;
  1587. case IDC_CONTROL_CHARS:
  1588. g_ScriptState.fDisplayZWG = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1589. InvalidateText();
  1590. return TRUE;
  1591. case IDC_LOGICAL_ORDER:
  1592. g_fLogicalOrder = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1593. InvalidateText();
  1594. return TRUE;
  1595. case IDC_NO_GLYPH_INDEX:
  1596. g_fNoGlyphIndex = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1597. InvalidateText();
  1598. return TRUE;
  1599. case IDC_PLAINTEXT_FIT:
  1600. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED) {
  1601. g_dwSSAflags |= SSA_FIT;
  1602. } else {
  1603. g_dwSSAflags &= ~SSA_FIT;
  1604. }
  1605. InvalidateText();
  1606. return TRUE;
  1607. case IDC_PLAINTEXT_CLIP:
  1608. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED) {
  1609. g_dwSSAflags |= SSA_CLIP;
  1610. } else {
  1611. g_dwSSAflags &= ~SSA_CLIP;
  1612. }
  1613. InvalidateText();
  1614. return TRUE;
  1615. case IDC_PLAINTEXT_TAB:
  1616. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED) {
  1617. g_dwSSAflags |= SSA_TAB;
  1618. } else {
  1619. g_dwSSAflags &= ~SSA_TAB;
  1620. }
  1621. InvalidateText();
  1622. return TRUE;
  1623. case IDC_PLAINTEXT_DX:
  1624. g_fOverrideDx = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1625. memset(g_iWidthBuf, 0, sizeof(int)*g_iTextLen+1);
  1626. InvalidateText();
  1627. return TRUE;
  1628. case IDC_PLAINTEXT_FALLBACK:
  1629. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED) {
  1630. g_dwSSAflags |= SSA_FALLBACK;
  1631. } else {
  1632. g_dwSSAflags &= ~SSA_FALLBACK;
  1633. }
  1634. InvalidateText();
  1635. return TRUE;
  1636. case IDC_PLAINTEXT_LINK:
  1637. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED) {
  1638. g_dwSSAflags |= SSA_LINK;
  1639. } else {
  1640. g_dwSSAflags &= ~SSA_LINK;
  1641. }
  1642. InvalidateText();
  1643. return TRUE;
  1644. case IDC_PLAINTEXT_HOTKEY:
  1645. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED) {
  1646. g_dwSSAflags |= SSA_HOTKEY;
  1647. } else {
  1648. g_dwSSAflags &= ~SSA_HOTKEY;
  1649. }
  1650. InvalidateText();
  1651. return TRUE;
  1652. case IDC_PLAINTEXT_PASSWORD:
  1653. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED) {
  1654. g_dwSSAflags |= SSA_PASSWORD;
  1655. } else {
  1656. g_dwSSAflags &= ~SSA_PASSWORD;
  1657. }
  1658. InvalidateText();
  1659. return TRUE;
  1660. case IDC_FORMATTED:
  1661. g_fShowFancyText = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1662. InvalidateText();
  1663. return TRUE;
  1664. case IDC_FANCY_FONT1:
  1665. case IDC_FANCY_SIZE1:
  1666. if (iNotify != CBN_SELCHANGE) {
  1667. return FALSE;
  1668. }
  1669. case IDC_FANCY_BOLD1:
  1670. case IDC_FANCY_ITALIC1:
  1671. case IDC_FANCY_UNDERLINE1:
  1672. ChangeFont(
  1673. hDlg,
  1674. 1,
  1675. IDC_FANCY_FONT1,
  1676. IDC_FANCY_SIZE1,
  1677. IDC_FANCY_BOLD1,
  1678. IDC_FANCY_ITALIC1,
  1679. IDC_FANCY_UNDERLINE1);
  1680. return TRUE;
  1681. case IDC_FANCY_FONT2:
  1682. case IDC_FANCY_SIZE2:
  1683. if (iNotify != CBN_SELCHANGE) {
  1684. return FALSE;
  1685. }
  1686. case IDC_FANCY_BOLD2:
  1687. case IDC_FANCY_ITALIC2:
  1688. case IDC_FANCY_UNDERLINE2:
  1689. ChangeFont(
  1690. hDlg,
  1691. 2,
  1692. IDC_FANCY_FONT2,
  1693. IDC_FANCY_SIZE2,
  1694. IDC_FANCY_BOLD2,
  1695. IDC_FANCY_ITALIC2,
  1696. IDC_FANCY_UNDERLINE2);
  1697. return TRUE;
  1698. case IDC_FANCY_FONT3:
  1699. case IDC_FANCY_SIZE3:
  1700. if (iNotify != CBN_SELCHANGE) {
  1701. return FALSE;
  1702. }
  1703. case IDC_FANCY_BOLD3:
  1704. case IDC_FANCY_ITALIC3:
  1705. case IDC_FANCY_UNDERLINE3:
  1706. ChangeFont(
  1707. hDlg,
  1708. 3,
  1709. IDC_FANCY_FONT3,
  1710. IDC_FANCY_SIZE3,
  1711. IDC_FANCY_BOLD3,
  1712. IDC_FANCY_ITALIC3,
  1713. IDC_FANCY_UNDERLINE3);
  1714. return TRUE;
  1715. case IDC_FANCY_FONT4:
  1716. case IDC_FANCY_SIZE4:
  1717. if (iNotify != CBN_SELCHANGE) {
  1718. return FALSE;
  1719. }
  1720. case IDC_FANCY_BOLD4:
  1721. case IDC_FANCY_ITALIC4:
  1722. case IDC_FANCY_UNDERLINE4:
  1723. ChangeFont(
  1724. hDlg,
  1725. 4,
  1726. IDC_FANCY_FONT4,
  1727. IDC_FANCY_SIZE4,
  1728. IDC_FANCY_BOLD4,
  1729. IDC_FANCY_ITALIC4,
  1730. IDC_FANCY_UNDERLINE4);
  1731. return TRUE;
  1732. case IDC_FORMAT1:
  1733. case IDC_FORMAT2:
  1734. case IDC_FORMAT3:
  1735. case IDC_FORMAT4:
  1736. if (g_iTo < g_iFrom) {
  1737. i=g_iTo; g_iTo=g_iFrom; g_iFrom=i;
  1738. }
  1739. if ( g_iFrom < g_iTo
  1740. && g_iFrom < g_iTextLen
  1741. && g_iTo <= g_iTextLen) {
  1742. i=1; // Default
  1743. switch(iCmd) {
  1744. case IDC_FORMAT1: i=1; break;
  1745. case IDC_FORMAT2: i=2; break;
  1746. case IDC_FORMAT3: i=3; break;
  1747. case IDC_FORMAT4: i=4; break;
  1748. }
  1749. StyleSetRange(i, g_iFrom, g_iTo-g_iFrom);
  1750. ASSERT(StyleCheckRange());
  1751. InvalidateText();
  1752. }
  1753. return TRUE;
  1754. case IDC_APPLYDIGITSUBST:
  1755. ScriptApplyDigitSubstitution(NULL, &g_ScriptControl, &g_ScriptState);
  1756. SendDlgItemMessage(hDlg, IDC_DIGIT_SUBSTITUTE, BM_SETCHECK, g_ScriptState.fDigitSubstitute ? BST_CHECKED : BST_UNCHECKED, 0);
  1757. SendDlgItemMessage(hDlg, IDC_CONTROL_CONTEXT, BM_SETCHECK, g_ScriptControl.fContextDigits ? BST_CHECKED : BST_UNCHECKED, 0);
  1758. str[0] = '0';
  1759. str[1] = 'x';
  1760. str[2] = hex[(g_ScriptControl.uDefaultLanguage & 0xf0) >> 4];
  1761. str[3] = hex[ g_ScriptControl.uDefaultLanguage & 0x0f];
  1762. str[4] = 0;
  1763. SendDlgItemMessage(hDlg, IDC_LANGUAGE, CB_SELECTSTRING, 0, (LPARAM) str);
  1764. InvalidateText();
  1765. return TRUE;
  1766. case IDC_PRESENTATION:
  1767. g_fPresentation = TRUE;
  1768. ShowWindow(g_hSettingsDlg, SW_HIDE);
  1769. SetFocus(g_hTextWnd);
  1770. InvalidateText();
  1771. return TRUE;
  1772. */
  1773. } // end switch
  1774. return FALSE;
  1775. }
  1776. BOOL GetDropListValue(HWND hDlg, INT iCmd, INT iNotify, char *str, INT strlen)
  1777. {
  1778. switch (iNotify)
  1779. {
  1780. case CBN_EDITCHANGE:
  1781. return GetDlgItemTextA(hDlg, iCmd, str, strlen);
  1782. case CBN_SELCHANGE:
  1783. return SendDlgItemMessage(
  1784. hDlg,
  1785. iCmd,
  1786. CB_GETLBTEXT,
  1787. SendDlgItemMessage(hDlg, iCmd, CB_GETCURSEL, 0, 0),
  1788. (LPARAM)str
  1789. ) != CB_ERR;
  1790. }
  1791. return FALSE;
  1792. }
  1793. BOOL DriverSettingsCommand(HWND hDlg, int iCmd, int iNotify, HWND hItemWnd) {
  1794. char str[100];
  1795. switch(iCmd) {
  1796. // Driver strings
  1797. case IDC_DRIVERCMAP:
  1798. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED)
  1799. {
  1800. g_DriverOptions |= DriverStringOptionsCmapLookup;
  1801. }
  1802. else
  1803. {
  1804. g_DriverOptions &= ~DriverStringOptionsCmapLookup;
  1805. }
  1806. InvalidateText();
  1807. return TRUE;
  1808. case IDC_DRIVERVERTICAL:
  1809. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED)
  1810. {
  1811. g_DriverOptions |= DriverStringOptionsVertical;
  1812. }
  1813. else
  1814. {
  1815. g_DriverOptions &= ~DriverStringOptionsVertical;
  1816. }
  1817. InvalidateText();
  1818. return TRUE;
  1819. case IDC_DRIVERREALIZEDADVANCE:
  1820. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED)
  1821. {
  1822. g_DriverOptions |= DriverStringOptionsRealizedAdvance;
  1823. }
  1824. else
  1825. {
  1826. g_DriverOptions &= ~DriverStringOptionsRealizedAdvance;
  1827. }
  1828. InvalidateText();
  1829. return TRUE;
  1830. case IDC_DRIVERDX:
  1831. if (GetDropListValue(hDlg, iCmd, iNotify, str, sizeof(str)))
  1832. {
  1833. g_DriverDx = REAL(atof(str));
  1834. InvalidateText();
  1835. }
  1836. return TRUE;
  1837. case IDC_DRIVERDY:
  1838. if (GetDropListValue(hDlg, iCmd, iNotify, str, sizeof(str)))
  1839. {
  1840. g_DriverDy = REAL(atof(str));
  1841. InvalidateText();
  1842. }
  1843. return TRUE;
  1844. case IDC_LIMITSUBPIXEL:
  1845. if (IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED)
  1846. {
  1847. g_DriverOptions |= DriverStringOptionsLimitSubpixel;
  1848. }
  1849. else
  1850. {
  1851. g_DriverOptions &= ~DriverStringOptionsLimitSubpixel;
  1852. }
  1853. InvalidateText();
  1854. return TRUE;
  1855. case IDC_DRIVERORIGINALPIXELS:
  1856. if (GetDropListValue(hDlg, iCmd, iNotify, str, sizeof(str)))
  1857. {
  1858. g_DriverPixels = REAL(atof(str));
  1859. InvalidateText();
  1860. }
  1861. return TRUE;
  1862. } // end switch
  1863. return FALSE;
  1864. }
  1865. BOOL GlyphSettingsCommand(HWND hDlg, int iCmd, int iNotify, HWND hItemWnd) {
  1866. char str[100];
  1867. switch(iCmd) {
  1868. case IDC_GLYPHCMAPLOOKUP:
  1869. g_CmapLookup = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1870. InvalidateText();
  1871. return TRUE;
  1872. case IDC_GLYPHHORIZONTALCHART:
  1873. g_HorizontalChart = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1874. InvalidateText();
  1875. return TRUE;
  1876. case IDC_GLYPHSHOWCELL:
  1877. g_ShowCell = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1878. InvalidateText();
  1879. return TRUE;
  1880. case IDC_GLYPHVERTICALFORMS:
  1881. g_VerticalForms = IsDlgButtonChecked(hDlg, iCmd) == BST_CHECKED;
  1882. InvalidateText();
  1883. return TRUE;
  1884. case IDC_GLYPHROWS:
  1885. if (GetDropListValue(hDlg, iCmd, iNotify, str, sizeof(str)))
  1886. {
  1887. g_GlyphRows = atoi(str);
  1888. if (g_GlyphRows > 64) g_GlyphRows = 64;
  1889. InvalidateText();
  1890. }
  1891. return TRUE;
  1892. case IDC_GLYPHCOLUMNS:
  1893. if (GetDropListValue(hDlg, iCmd, iNotify, str, sizeof(str)))
  1894. {
  1895. g_GlyphColumns = atoi(str);
  1896. if (g_GlyphColumns > 64) g_GlyphColumns = 64;
  1897. InvalidateText();
  1898. }
  1899. return TRUE;
  1900. case IDC_GLYPHINDEX:
  1901. if (GetDropListValue(hDlg, iCmd, iNotify, str, sizeof(str)))
  1902. {
  1903. g_GlyphFirst = HexToInt(str);
  1904. InvalidateText();
  1905. }
  1906. return TRUE;
  1907. } // end switch
  1908. return FALSE;
  1909. }
  1910. int CALLBACK InitOneFace(
  1911. const ENUMLOGFONTEXA *lpelfe, // pointer to logical-font data
  1912. const NEWTEXTMETRICEXA *lpntme, // pointer to physical-font data
  1913. int FontType, // type of font
  1914. LPARAM lParam) { // application-defined data
  1915. if (SendDlgItemMessage(
  1916. (HWND)lParam,
  1917. IDC_PLAINTEXT_FONT,
  1918. CB_FINDSTRINGEXACT,
  1919. 0, (LPARAM)lpelfe->elfLogFont.lfFaceName) == CB_ERR) {
  1920. // It's a new font name
  1921. SendDlgItemMessage(
  1922. (HWND)lParam,
  1923. IDC_PLAINTEXT_FONT,
  1924. CB_ADDSTRING,
  1925. 0, (LPARAM)lpelfe->elfLogFont.lfFaceName);
  1926. /*
  1927. SendDlgItemMessage(
  1928. (HWND)lParam,
  1929. IDC_FANCY_FONT1,
  1930. CB_ADDSTRING,
  1931. 0, (LPARAM)lpelfe->elfLogFont.lfFaceName);
  1932. SendDlgItemMessage(
  1933. (HWND)lParam,
  1934. IDC_FANCY_FONT2,
  1935. CB_ADDSTRING,
  1936. 0, (LPARAM)lpelfe->elfLogFont.lfFaceName);
  1937. SendDlgItemMessage(
  1938. (HWND)lParam,
  1939. IDC_FANCY_FONT3,
  1940. CB_ADDSTRING,
  1941. 0, (LPARAM)lpelfe->elfLogFont.lfFaceName);
  1942. SendDlgItemMessage(
  1943. (HWND)lParam,
  1944. IDC_FANCY_FONT4,
  1945. CB_ADDSTRING,
  1946. 0, (LPARAM)lpelfe->elfLogFont.lfFaceName);
  1947. */
  1948. }
  1949. return 1; // Continue enumeration
  1950. UNREFERENCED_PARAMETER(FontType);
  1951. UNREFERENCED_PARAMETER(lpntme);
  1952. }
  1953. void InitOneSize(
  1954. HWND hDlg,
  1955. char *str) {
  1956. SendDlgItemMessageA(hDlg, IDC_PLAINTEXT_SIZE, CB_ADDSTRING, 0, (LPARAM)str);
  1957. /*
  1958. SendDlgItemMessage(hDlg, IDC_FANCY_SIZE1, CB_ADDSTRING, 0, (LPARAM)str);
  1959. SendDlgItemMessage(hDlg, IDC_FANCY_SIZE2, CB_ADDSTRING, 0, (LPARAM)str);
  1960. SendDlgItemMessage(hDlg, IDC_FANCY_SIZE3, CB_ADDSTRING, 0, (LPARAM)str);
  1961. SendDlgItemMessage(hDlg, IDC_FANCY_SIZE4, CB_ADDSTRING, 0, (LPARAM)str);
  1962. */
  1963. }
  1964. void InitSelection(HWND hDlg, int idFace, int idSize, TCHAR *sFaceName) {
  1965. INT_PTR i;
  1966. i = SendDlgItemMessage(hDlg, idFace, CB_FINDSTRINGEXACT, 0, (LPARAM)sFaceName);
  1967. if (i == CB_ERR) {
  1968. SendDlgItemMessage(hDlg, idFace, CB_SETCURSEL, 0, 0);
  1969. } else {
  1970. SendDlgItemMessage(hDlg, idFace, CB_SETCURSEL, i, 0);
  1971. }
  1972. SendDlgItemMessage(hDlg, idSize, CB_SETCURSEL, 2, 0); // Selection 2 is 8 point
  1973. }
  1974. void InitFaceLists(HWND hDlg) {
  1975. HDC hdc;
  1976. LOGFONT lf;
  1977. memset(&lf, 0, sizeof(lf));
  1978. lf.lfCharSet = DEFAULT_CHARSET;
  1979. hdc = GetDC(g_hTextWnd);
  1980. EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)InitOneFace, (LPARAM)hDlg, 0);
  1981. // Hard coded addtion of MS Shell Dlg fonts
  1982. SendDlgItemMessage(hDlg, IDC_PLAINTEXT_FONT, CB_ADDSTRING, 0, (LPARAM)"MS Shell Dlg");
  1983. SendDlgItemMessage(hDlg, IDC_PLAINTEXT_FONT, CB_ADDSTRING, 0, (LPARAM)"MS Shell Dlg 2");
  1984. ReleaseDC(g_hTextWnd, hdc);
  1985. // Initialise sizes
  1986. InitOneSize(hDlg, "6");
  1987. InitOneSize(hDlg, "7");
  1988. InitOneSize(hDlg, "8");
  1989. InitOneSize(hDlg, "9");
  1990. InitOneSize(hDlg, "10");
  1991. InitOneSize(hDlg, "11");
  1992. InitOneSize(hDlg, "12");
  1993. InitOneSize(hDlg, "13");
  1994. InitOneSize(hDlg, "14");
  1995. InitOneSize(hDlg, "16");
  1996. InitOneSize(hDlg, "18");
  1997. InitOneSize(hDlg, "20");
  1998. InitOneSize(hDlg, "22");
  1999. InitOneSize(hDlg, "24");
  2000. InitOneSize(hDlg, "28");
  2001. InitOneSize(hDlg, "32");
  2002. InitOneSize(hDlg, "36");
  2003. InitOneSize(hDlg, "48");
  2004. InitOneSize(hDlg, "60");
  2005. InitOneSize(hDlg, "72");
  2006. InitOneSize(hDlg, "90");
  2007. InitOneSize(hDlg, "108");
  2008. InitOneSize(hDlg, "144");
  2009. InitOneSize(hDlg, "180");
  2010. InitOneSize(hDlg, "216");
  2011. InitOneSize(hDlg, "252");
  2012. InitOneSize(hDlg, "288");
  2013. InitOneSize(hDlg, "324");
  2014. InitOneSize(hDlg, "360");
  2015. InitOneSize(hDlg, "396");
  2016. InitOneSize(hDlg, "450");
  2017. InitOneSize(hDlg, "504");
  2018. InitOneSize(hDlg, "558");
  2019. InitOneSize(hDlg, "612");
  2020. InitOneSize(hDlg, "666");
  2021. InitOneSize(hDlg, "720");
  2022. #define MAXPOINTSIZE 720 // Keep same as point size in the previous line
  2023. // Select standard fonts and sizes
  2024. InitSelection(hDlg, IDC_PLAINTEXT_FONT, IDC_PLAINTEXT_SIZE, _TEXT("Microsoft Sans Serif"));
  2025. /*
  2026. InitSelection(hDlg, IDC_FANCY_FONT1, IDC_FANCY_SIZE1, "Tahoma");
  2027. InitSelection(hDlg, IDC_FANCY_FONT2, IDC_FANCY_SIZE2, "Mangal");
  2028. InitSelection(hDlg, IDC_FANCY_FONT3, IDC_FANCY_SIZE3, "Latha");
  2029. InitSelection(hDlg, IDC_FANCY_FONT4, IDC_FANCY_SIZE4, "Tahoma");
  2030. */
  2031. /*
  2032. ChangeFont(hDlg, 1, IDC_FANCY_FONT1, IDC_FANCY_SIZE1, IDC_FANCY_BOLD1, IDC_FANCY_ITALIC1, IDC_FANCY_UNDERLINE1);
  2033. ChangeFont(hDlg, 2, IDC_FANCY_FONT2, IDC_FANCY_SIZE2, IDC_FANCY_BOLD2, IDC_FANCY_ITALIC2, IDC_FANCY_UNDERLINE2);
  2034. ChangeFont(hDlg, 3, IDC_FANCY_FONT3, IDC_FANCY_SIZE3, IDC_FANCY_BOLD3, IDC_FANCY_ITALIC3, IDC_FANCY_UNDERLINE3);
  2035. ChangeFont(hDlg, 4, IDC_FANCY_FONT4, IDC_FANCY_SIZE4, IDC_FANCY_BOLD4, IDC_FANCY_ITALIC4, IDC_FANCY_UNDERLINE4);
  2036. */
  2037. };
  2038. void InitDropList(
  2039. HWND hDlg,
  2040. int id,
  2041. const char **strings,
  2042. int stringCount
  2043. )
  2044. {
  2045. INT i;
  2046. for (i=0; i<stringCount; i++) {
  2047. SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0, (LPARAM)strings[i]);
  2048. }
  2049. SendDlgItemMessage(hDlg, id, CB_SETCURSEL, 0, 0);
  2050. }
  2051. INT_PTR CALLBACK GlyphSettingsDlgProc(
  2052. HWND hDlg,
  2053. UINT uMsg,
  2054. WPARAM wParam,
  2055. LPARAM lParam
  2056. )
  2057. {
  2058. switch (uMsg)
  2059. {
  2060. case WM_INITDIALOG:
  2061. for (INT i=0; i < sizeof(szRows)/sizeof(szRows[0]); i++) {
  2062. SendDlgItemMessage(hDlg, IDC_GLYPHROWS, CB_ADDSTRING, 0, (LPARAM)szRows[i]);
  2063. SendDlgItemMessage(hDlg, IDC_GLYPHCOLUMNS, CB_ADDSTRING, 0, (LPARAM)szRows[i]);
  2064. }
  2065. SendDlgItemMessage(hDlg, IDC_GLYPHROWS, CB_SETCURSEL, 4, 0);
  2066. SendDlgItemMessage(hDlg, IDC_GLYPHCOLUMNS, CB_SETCURSEL, 4, 0);
  2067. InitDropList(hDlg, IDC_GLYPHINDEX, szOffsets, sizeof(szOffsets)/sizeof(szOffsets[0]));
  2068. fontTransform.init(GetDlgItem(hDlg, IDC_FONTTRANSFORM), &g_FontTransform);
  2069. return FALSE;
  2070. case WM_COMMAND:
  2071. GlyphSettingsCommand(hDlg, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
  2072. return FALSE;
  2073. }
  2074. return FALSE;
  2075. }
  2076. INT_PTR CALLBACK DriverSettingsDlgProc(
  2077. HWND hDlg,
  2078. UINT uMsg,
  2079. WPARAM wParam,
  2080. LPARAM lParam
  2081. )
  2082. {
  2083. switch (uMsg)
  2084. {
  2085. case WM_INITDIALOG:
  2086. InitDropList(hDlg, IDC_DRIVERDX, szDriverDx, sizeof(szDriverDx)/sizeof(szDriverDx[0]));
  2087. InitDropList(hDlg, IDC_DRIVERDY, szDriverDx, sizeof(szDriverDx)/sizeof(szDriverDx[0]));
  2088. InitDropList(hDlg, IDC_DRIVERORIGINALPIXELS, szDriverPixels, sizeof(szDriverPixels)/sizeof(szDriverPixels[0]));
  2089. SendDlgItemMessage(hDlg, IDC_DRIVERDX, CB_SETCURSEL, 2, 0);
  2090. SendDlgItemMessage(hDlg, IDC_DRIVERDY, CB_SETCURSEL, 0, 0);
  2091. SendDlgItemMessage(hDlg, IDC_DRIVERORIGINALPIXELS, CB_SETCURSEL, 5, 0);
  2092. driverTransform.init(GetDlgItem(hDlg, IDC_DRIVERTRANSFORM), &g_DriverTransform);
  2093. SendDlgItemMessage(hDlg, IDC_DRIVERCMAP, BM_SETCHECK, BST_CHECKED, 0);
  2094. SendDlgItemMessage(hDlg, IDC_DRIVERREALIZEDADVANCE, BM_SETCHECK, BST_CHECKED, 0);
  2095. return FALSE;
  2096. case WM_COMMAND:
  2097. DriverSettingsCommand(hDlg, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
  2098. return FALSE;
  2099. }
  2100. return FALSE;
  2101. }
  2102. INT_PTR CALLBACK SettingsDlgProc(
  2103. HWND hDlg,
  2104. UINT uMsg,
  2105. WPARAM wParam,
  2106. LPARAM lParam
  2107. )
  2108. {
  2109. int i;
  2110. switch (uMsg)
  2111. {
  2112. case WM_INITDIALOG:
  2113. // Populate the Unicode codepoint combo box
  2114. for (i=0; i<sizeof(szUniChar)/sizeof(szUniChar[0]); i++) {
  2115. SendDlgItemMessageA(hDlg, IDC_CODEPOINT, CB_ADDSTRING, 0, (LPARAM)szUniChar[i]);
  2116. }
  2117. /*
  2118. for (i=0; i<sizeof(szLanguage)/sizeof(szLanguage[0]); i++) {
  2119. SendDlgItemMessage(hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)szLanguage[i]);
  2120. }
  2121. SendDlgItemMessage(hDlg, IDC_LANGUAGE, CB_SETCURSEL, 0, 0);
  2122. */
  2123. InitDropList(hDlg, IDC_ALIGNMENT, szAlignments, sizeof(szAlignments)/sizeof(szAlignments[0]));
  2124. InitDropList(hDlg, IDC_FONTUNIT, szUnits, sizeof(szUnits)/sizeof(szUnits[0]));
  2125. InitDropList(hDlg, IDC_FOREBRUSHTYPE, szForeGroundBrush, sizeof(szForeGroundBrush)/sizeof(szForeGroundBrush[0]));
  2126. InitDropList(hDlg, IDC_BACKBRUSHTYPE, szBackGroundBrush, sizeof(szBackGroundBrush)/sizeof(szBackGroundBrush[0]));
  2127. InitDropList(hDlg, IDC_TEXTMODE, szTextMode, sizeof(szTextMode)/sizeof(szTextMode[0]));
  2128. InitDropList(hDlg, IDC_DIGIT_SUBSTITUTE, szDigitSubstitute, sizeof(szDigitSubstitute)/sizeof(szDigitSubstitute[0]));
  2129. InitDropList(hDlg, IDC_LANGUAGE, szLanguage, sizeof(szLanguage)/sizeof(szLanguage[0]));
  2130. GetTextForeGroundBrush(0);
  2131. GetTextBackGroundBrush(0);
  2132. SendDlgItemMessage(hDlg, IDC_FONTUNIT, CB_SETCURSEL, 3, 0);
  2133. //InitDropList(hDlg, IDC_RENDERER, szRenderers, sizeof(szRenderers)/sizeof(szRenderers[0]));
  2134. InitFaceLists(hDlg);
  2135. if (g_ShowFamilies) SendDlgItemMessage(hDlg, IDC_SHOWFAMILIES, BM_SETCHECK, BST_CHECKED, 0);
  2136. if (g_ShowLogical) SendDlgItemMessage(hDlg, IDC_LOGICAL, BM_SETCHECK, BST_CHECKED, 0);
  2137. if (g_ShowGlyphs) SendDlgItemMessage(hDlg, IDC_SHOWGLYPHS, BM_SETCHECK, BST_CHECKED, 0);
  2138. if (g_ShowDrawString) SendDlgItemMessage(hDlg, IDC_SHOWDRAWSTRING, BM_SETCHECK, BST_CHECKED, 0);
  2139. if (g_Bold) SendDlgItemMessage(hDlg, IDC_PLAINTEXT_BOLD, BM_SETCHECK, BST_CHECKED, 0);
  2140. if (g_Italic) SendDlgItemMessage(hDlg, IDC_PLAINTEXT_ITALIC, BM_SETCHECK, BST_CHECKED, 0);
  2141. if (g_Underline) SendDlgItemMessage(hDlg, IDC_PLAINTEXT_UNDERLINE, BM_SETCHECK, BST_CHECKED, 0);
  2142. if (g_Strikeout) SendDlgItemMessage(hDlg, IDC_PLAINTEXT_STRIKEOUT, BM_SETCHECK, BST_CHECKED, 0);
  2143. SendDlgItemMessage(hDlg, IDC_PLAINTEXT_FONT, CB_SELECTSTRING, -1, (LPARAM)g_szFaceName);
  2144. // Make sure the control shows the proper selection...
  2145. SendDlgItemMessage(hDlg, IDC_TEXTMODE, CB_SETCURSEL, g_TextMode, 0);
  2146. /*
  2147. SendDlgItemMessage(hDlg, IDC_LTR, BM_SETSTATE, TRUE, 0);
  2148. SendDlgItemMessage(hDlg, IDC_HORIZ, BM_SETSTATE, TRUE, 0);
  2149. SendDlgItemMessage(hDlg, IDC_LOGICAL, BM_SETCHECK, BST_CHECKED, 0);
  2150. SendDlgItemMessage(hDlg, IDC_PLAINTEXT, BM_SETCHECK, BST_CHECKED, 0);
  2151. SendDlgItemMessage(hDlg, IDC_FORMATTED, BM_SETCHECK, BST_CHECKED, 0);
  2152. SendDlgItemMessage(hDlg, IDC_LINEFILL, BM_SETCHECK, BST_CHECKED, 0);
  2153. SendDlgItemMessage(hDlg, IDC_PLAINTEXT_FALLBACK, BM_SETCHECK, BST_CHECKED, 0);
  2154. */
  2155. SendDlgItemMessage(hDlg, IDC_FONTSIZE, TBM_SETRANGE, 0, MAKELONG(1,MAXPOINTSIZE));
  2156. SendDlgItemMessage(hDlg, IDC_FONTSIZE, TBM_SETPOS, TRUE, g_iFontHeight);
  2157. SendDlgItemMessage(hDlg, IDC_GAMMAVALUE, TBM_SETRANGE, 0, MAKELONG(0,12));
  2158. SendDlgItemMessage(hDlg, IDC_GAMMAVALUE, TBM_SETPOS, TRUE, 4);
  2159. worldTransform.init(GetDlgItem(hDlg, IDC_WORLDTRANSFORM), &g_WorldTransform);
  2160. return FALSE;
  2161. case WM_COMMAND:
  2162. Command(hDlg, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
  2163. return FALSE;
  2164. case WM_NOTIFY:
  2165. /*
  2166. char str[200];
  2167. wsprintf(str, "WM_NOTIFY (hDlg %x, IDC_FONTSIZE %x = wnd %x), hwnd %x, hwndFrom %x, idFrom %x, code %x.\n",
  2168. hDlg,
  2169. IDC_FONTSIZE,
  2170. GetDlgItem(hDlg, IDC_FONTSIZE),
  2171. wParam,
  2172. ((NMHDR*)lParam)->hwndFrom,
  2173. ((NMHDR*)lParam)->idFrom,
  2174. ((NMHDR*)lParam)->code
  2175. );
  2176. OutputDebugString(str);
  2177. */
  2178. if ( ((NMHDR*)lParam)->idFrom == IDC_GAMMAVALUE
  2179. && ((NMHDR*)lParam)->code == NM_CUSTOMDRAW)
  2180. {
  2181. // Update font size
  2182. g_GammaValue = (UINT)SendDlgItemMessage(hDlg, IDC_GAMMAVALUE, TBM_GETPOS, 0, 0);
  2183. InvalidateText();
  2184. }
  2185. if ( ((NMHDR*)lParam)->idFrom == IDC_FONTSIZE
  2186. && ((NMHDR*)lParam)->code == NM_CUSTOMDRAW)
  2187. {
  2188. // Update font size
  2189. INT pos = (INT)SendDlgItemMessage(hDlg, IDC_FONTSIZE, TBM_GETPOS, 0, 0);
  2190. char str[100];
  2191. wsprintfA(str, "%d", pos);
  2192. /*
  2193. OutputDebugString("Pos: ");
  2194. OutputDebugString(str);
  2195. OutputDebugString("\n");
  2196. */
  2197. SendDlgItemMessageA(hDlg, IDC_PLAINTEXT_SIZE, WM_SETTEXT, 0, (LPARAM)str);
  2198. // Get facename
  2199. UINT_PTR i = SendDlgItemMessage(hDlg, IDC_PLAINTEXT_FONT, CB_GETCURSEL, 0, 0);
  2200. TCHAR sFaceName[100];
  2201. if (SendDlgItemMessage(hDlg, IDC_PLAINTEXT_FONT, CB_GETLBTEXT, i, (LPARAM)sFaceName) == CB_ERR) {
  2202. return FALSE;
  2203. }
  2204. SetStyle(
  2205. 0,
  2206. pos,
  2207. IsDlgButtonChecked(hDlg, IDC_PLAINTEXT_BOLD) == BST_CHECKED ? 700 : 400,
  2208. IsDlgButtonChecked(hDlg, IDC_PLAINTEXT_ITALIC) == BST_CHECKED,
  2209. IsDlgButtonChecked(hDlg, IDC_PLAINTEXT_UNDERLINE) == BST_CHECKED,
  2210. IsDlgButtonChecked(hDlg, IDC_PLAINTEXT_STRIKEOUT) == BST_CHECKED,
  2211. sFaceName
  2212. );
  2213. InvalidateText();
  2214. }
  2215. return FALSE;
  2216. }
  2217. return FALSE;
  2218. }