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

175 lines
4.6 KiB

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <commctrl.h>
  5. #include <memory.h>
  6. #include "hugetest.h"
  7. #include "resource.h"
  8. #include "macros.h"
  9. #ifndef NO_UI_IN_CNFG
  10. extern HINSTANCE hInstance;
  11. typedef BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
  12. DlgProc hugeBufferDlgProc; // buffers.cpp
  13. DlgProc hugeFogDlgProc; // fog.cpp
  14. DlgProc hugeLightDlgProc; // lighting.cpp
  15. DlgProc hugeRasterDlgProc; // raster.cpp
  16. DlgProc hugeTextureDlgProc; // texture.cpp
  17. DlgProc hugeDummyDlgProc;
  18. void VerifyEditboxFloat(HWND hDlg, int iControl)
  19. {
  20. char aBuf[20];
  21. double d;
  22. GetDlgItemText(hDlg, iControl, aBuf, sizeof(aBuf));
  23. d = atof(aBuf);
  24. sprintf(aBuf,"%g",d);
  25. SetDlgItemText(hDlg, iControl, aBuf);
  26. }
  27. void SetDlgFloatString(HWND hDlg, int iControl, GLfloat f)
  28. {
  29. char aBuf[20];
  30. sprintf(aBuf,"%g",f);
  31. SetDlgItemText(hDlg, iControl, aBuf);
  32. }
  33. GLfloat GetDlgFloatString(HWND hDlg, int iControl)
  34. {
  35. char aBuf[20];
  36. GetDlgItemText(hDlg, iControl, aBuf, sizeof(aBuf));
  37. return (GLfloat) atof(aBuf);
  38. }
  39. void VerifyEditboxHex(HWND hDlg, int iControl)
  40. {
  41. char aBuf[20];
  42. ushort us;
  43. GetDlgItemText(hDlg, iControl, aBuf, sizeof(aBuf));
  44. us = (ushort) strtol(aBuf, NULL, 0);
  45. sprintf(aBuf,"0x%04X", us);
  46. SetDlgItemText(hDlg, iControl, aBuf);
  47. }
  48. void SetDlgHexString(HWND hDlg, int iControl, ushort us)
  49. {
  50. char aBuf[20];
  51. sprintf(aBuf,"0x%04X",us);
  52. SetDlgItemText(hDlg, iControl, aBuf);
  53. }
  54. ushort GetDlgHexString(HWND hDlg, int iControl)
  55. {
  56. char aBuf[20];
  57. GetDlgItemText(hDlg, iControl, aBuf, sizeof(aBuf));
  58. return (ushort) strtol(aBuf, NULL, 0);
  59. }
  60. void HugeTest::UI_init()
  61. {
  62. PROPSHEETPAGE pspage[6];
  63. // Zero out property PAGE data
  64. bzero (&pspage, sizeof(pspage)) ;
  65. pspage[0].dwSize = sizeof(PROPSHEETPAGE);
  66. pspage[0].dwFlags = PSP_USECALLBACK;
  67. pspage[0].hInstance = hInstance;
  68. pspage[0].pszTemplate = MAKEINTRESOURCE (IDD_BUFFERS);
  69. pspage[0].pfnDlgProc = (DLGPROC) hugeBufferDlgProc;
  70. pspage[0].lParam = (LPARAM) &bd;
  71. pspage[1].dwSize = sizeof(PROPSHEETPAGE);
  72. pspage[1].dwFlags = PSP_USECALLBACK;
  73. pspage[1].hInstance = hInstance;
  74. pspage[1].pszTemplate = MAKEINTRESOURCE (IDD_FOG);
  75. pspage[1].pfnDlgProc = (DLGPROC) hugeFogDlgProc;
  76. pspage[1].lParam = (LPARAM) &fd;
  77. pspage[2].dwSize = sizeof(PROPSHEETPAGE);
  78. pspage[2].dwFlags = PSP_USECALLBACK;
  79. pspage[2].hInstance = hInstance;
  80. pspage[2].pszTemplate = MAKEINTRESOURCE (IDD_LIGHTING);
  81. pspage[2].pfnDlgProc = (DLGPROC) hugeLightDlgProc;
  82. pspage[2].lParam = (LPARAM) &ld;
  83. pspage[3].dwSize = sizeof(PROPSHEETPAGE);
  84. pspage[3].dwFlags = PSP_USECALLBACK;
  85. pspage[3].hInstance = hInstance;
  86. pspage[3].pszTemplate = MAKEINTRESOURCE (IDD_RASTERIZATION);
  87. pspage[3].pfnDlgProc = (DLGPROC) hugeRasterDlgProc;
  88. pspage[3].lParam = (LPARAM) &rd;
  89. pspage[4].dwSize = sizeof(PROPSHEETPAGE);
  90. pspage[4].dwFlags = PSP_USECALLBACK;
  91. pspage[4].hInstance = hInstance;
  92. pspage[4].pszTemplate = MAKEINTRESOURCE (IDD_TEXTURING);
  93. pspage[4].pfnDlgProc = (DLGPROC) hugeTextureDlgProc;
  94. pspage[4].lParam = (LPARAM) &xd;
  95. AddPropertyPages(5, pspage);
  96. }
  97. BOOL CALLBACK hugeDummyDlgProc(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
  98. {
  99. switch (msg)
  100. {
  101. case WM_INITDIALOG:
  102. return TRUE;
  103. case WM_COMMAND:
  104. {
  105. int iControl, iNote;
  106. iControl = LOWORD(wParam);
  107. iNote = HIWORD(wParam); // notification code for edit boxes
  108. switch (iControl)
  109. {
  110. case P_IDC_POINT1:
  111. case P_IDC_POINT2:
  112. case P_IDC_POINT3:
  113. if (EN_KILLFOCUS == iNote) {
  114. PropSheet_Changed(GetParent(hDlg),hDlg);
  115. VerifyEditboxFloat(hDlg,iControl);
  116. }
  117. break;
  118. default:
  119. PropSheet_Changed(GetParent(hDlg),hDlg);
  120. break;
  121. }
  122. }
  123. break;
  124. case WM_NOTIFY:
  125. {
  126. LPNMHDR pnmh = (LPNMHDR) lParam;
  127. switch (pnmh->code)
  128. {
  129. case PSN_APPLY: // user clicked on OK or Apply
  130. break;
  131. case PSN_RESET: // user clicked on Cancel
  132. break;
  133. case PSN_HELP: // user clicked help
  134. break;
  135. }
  136. }
  137. break;
  138. default:
  139. return FALSE;
  140. }
  141. return TRUE;
  142. }
  143. #else
  144. void HugeTest::UI_init() {};
  145. #endif // NO_UI_IN_CNFG