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.

185 lines
8.6 KiB

  1. #include "scicalc.h"
  2. #include "calchelp.h"
  3. #include "unifunc.h"
  4. #define RED RGB(255,0,0) /* Red */
  5. #define PURPLE RGB(255,0,255) /* Dark Purple */
  6. #define BLUE RGB(0,0,255) /* Blue */
  7. #define DKBLUE RGB(0,0,255) /* Dark Blue */
  8. #define MAGENTA RGB(255,0,255) /* Magenta */
  9. #define DKRED RGB(255,0,0) /* Dark Red. */
  10. #define WHITE RGB(255,255,255) /* White */
  11. #define BLACK RGB(0,0,0) /* Black */
  12. extern BOOL g_fHighContrast;
  13. typedef struct
  14. {
  15. COLORREF crColor; // text color
  16. DWORD iHelpID; // the helpfile ID for this key
  17. // int bUnary :1, // true if this key is treated as a unary operator
  18. // bBinary :1, // true if this key is a binary operator
  19. // bUseInv :1, // true if this key deactivates the Inv checkbox when used
  20. // bUseHyp :1; // true if this key deactivates the Hyp checkbox when used
  21. } KEYDATA;
  22. // Control ID, Color, Help ID, Unary, Binary, Inv, Hyp
  23. KEYDATA keys[] = {
  24. { /*IDC_SIGN, */ BLUE, CALC_STD_SIGN, /*false, false, false, false*/ },
  25. { /*IDC_CLEAR, */ DKRED, CALC_C, /*false, false, false, false*/ },
  26. { /*IDC_CENTR, */ DKRED, CALC_CE, /*false, false, false, false*/ },
  27. { /*IDC_BACK, */ DKRED, CALC_BACK, /*false, false, false, false*/ },
  28. { /*IDC_STAT, */ DKBLUE, CALC_SCI_STA, /*false, false, false, false*/ },
  29. { /*IDC_PNT, */ BLUE, CALC_STD_DECIMAL, /*false, false, false, false*/ },
  30. { /*IDC_AND, */ RED, CALC_SCI_AND, /*false, false, false, false*/ },
  31. { /*IDC_OR, */ RED, CALC_SCI_OR, /*false, false, false, false*/ },
  32. { /*IDC_XOR, */ RED, CALC_SCI_XOR, /*false, false, false, false*/ },
  33. { /*IDC_LSHF, */ RED, CALC_SCI_LSH, /*false, false, false, false*/ },
  34. { /*IDC_DIV, */ RED, CALC_STD_SLASH, /*false, false, false, false*/ },
  35. { /*IDC_MUL, */ RED, CALC_STD_ASTERISK, /*false, false, false, false*/ },
  36. { /*IDC_ADD, */ RED, CALC_STD_PLUS, /*false, false, false, false*/ },
  37. { /*IDC_SUB, */ RED, CALC_STD_MINUS, /*false, false, false, false*/ },
  38. { /*IDC_MOD, */ RED, CALC_SCI_MOD, /*false, false, false, false*/ },
  39. { /*IDC_PWR, */ PURPLE, CALC_SCI_XCARETY, /*false, false, false, false*/ },
  40. { /*IDC_CHOP, */ RED, CALC_SCI_INT, /*false, false, false, false*/ },
  41. { /*IDC_COM, */ RED, CALC_SCI_NOT, /*false, false, false, false*/ },
  42. { /*IDC_SIN, */ PURPLE, CALC_SCI_SIN, /*false, false, false, false*/ },
  43. { /*IDC_COS, */ PURPLE, CALC_SCI_COS, /*false, false, false, false*/ },
  44. { /*IDC_TAN, */ PURPLE, CALC_SCI_TAN, /*false, false, false, false*/ },
  45. { /*IDC_LN, */ PURPLE, CALC_SCI_LN, /*false, false, false, false*/ },
  46. { /*IDC_LOG, */ PURPLE, CALC_SCI_LOG, /*false, false, false, false*/ },
  47. { /*IDC_SQRT, */ DKBLUE, CALC_STD_SQRT, /*false, false, false, false*/ },
  48. { /*IDC_SQR, */ PURPLE, CALC_SCI_XCARET2, /*false, false, false, false*/ },
  49. { /*IDC_CUB, */ PURPLE, CALC_SCI_XCARET3, /*false, false, false, false*/ },
  50. { /*IDC_FAC, */ PURPLE, CALC_SCI_FACTORIAL, /*false, false, false, false*/ },
  51. { /*IDC_REC, */ PURPLE, CALC_1X, /*false, false, false, false*/ },
  52. { /*IDC_DMS, */ PURPLE, CALC_SCI_DMS, /*false, false, false, false*/ },
  53. { /*IDC_PERCENT,*/ DKBLUE, CALC_STD_PERCENT, /*false, false, false, false*/ },
  54. { /*IDC_FE, */ PURPLE, CALC_SCI_FE, /*false, false, false, false*/ },
  55. { /*IDC_PI, */ DKBLUE, CALC_SCI_PI, /*false, false, false, false*/ },
  56. { /*IDC_EQU, */ RED, CALC_STD_EQUAL, /*false, false, false, false*/ },
  57. { /*IDC_MCLEAR, */ RED, CALC_MC, /*false, false, false, false*/ },
  58. { /*IDC_RECALL, */ RED, CALC_MR, /*false, false, false, false*/ },
  59. { /*IDC_STORE, */ RED, CALC_MS, /*false, false, false, false*/ },
  60. { /*IDC_MPLUS, */ RED, CALC_MPLUS, /*false, false, false, false*/ },
  61. { /*IDC_EXP, */ PURPLE, CALC_SCI_EXP, /*false, false, false, false*/ },
  62. { /*IDC_AVE, */ DKBLUE, CALC_SCI_AVE, /*false, false, false, false*/ },
  63. { /*IDC_B_SUM, */ DKBLUE, CALC_SCI_SUM, /*false, false, false, false*/ },
  64. { /*IDC_DEV, */ DKBLUE, CALC_SCI_S, /*false, false, false, false*/ },
  65. { /*IDC_DATA, */ DKBLUE, CALC_SCI_DAT, /*false, false, false, false*/ },
  66. { /*IDC_OPENP, */ PURPLE, CALC_SCI_OPENPAREN, /*false, false, false, false*/ },
  67. { /*IDC_CLOSEP, */ PURPLE, CALC_SCI_CLOSEPAREN,/*false, false, false, false*/ },
  68. { /*IDC_0, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  69. { /*IDC_1, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  70. { /*IDC_2, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  71. { /*IDC_3, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  72. { /*IDC_4, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  73. { /*IDC_5, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  74. { /*IDC_6, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  75. { /*IDC_7, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  76. { /*IDC_8, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  77. { /*IDC_9, */ BLUE, CALC_STD_NUMBERS, /*false, false, false, false*/ },
  78. { /*IDC_A, */ DKBLUE, CALC_SCI_ABCDEF, /*false, false, false, false*/ },
  79. { /*IDC_B, */ DKBLUE, CALC_SCI_ABCDEF, /*false, false, false, false*/ },
  80. { /*IDC_C, */ DKBLUE, CALC_SCI_ABCDEF, /*false, false, false, false*/ },
  81. { /*IDC_D, */ DKBLUE, CALC_SCI_ABCDEF, /*false, false, false, false*/ },
  82. { /*IDC_E, */ DKBLUE, CALC_SCI_ABCDEF, /*false, false, false, false*/ },
  83. { /*IDC_F, */ DKBLUE, CALC_SCI_ABCDEF, /*false, false, false, false*/ }
  84. };
  85. // Returns true if the given ID is one of Calc's command buttons
  86. BOOL IsValidID( int iID )
  87. {
  88. if ( (iID >= IDC_SIGN) && (iID <= IDC_F) )
  89. return TRUE;
  90. return FALSE;
  91. }
  92. // Used when processing WM_DRAWITEM to get the key color
  93. COLORREF GetKeyColor( int iID )
  94. {
  95. if ( g_fHighContrast || !IsValidID( iID ))
  96. return GetSysColor(COLOR_BTNTEXT);
  97. if ( nCalc && (iID == IDC_REC) )
  98. return DKBLUE;
  99. return keys[INDEXFROMID(iID)].crColor;
  100. }
  101. // Used when processing WM_CONTEXTHELP to get the Help ID.
  102. // This works for any control ID, not just the command buttons.
  103. ULONG_PTR GetHelpID( int iID )
  104. {
  105. if ( IsValidID( iID ) )
  106. {
  107. return keys[INDEXFROMID(iID)].iHelpID;
  108. }
  109. switch( iID )
  110. {
  111. case IDC_HEX:
  112. return CALC_SCI_HEX;
  113. case IDC_DEC:
  114. return CALC_SCI_DEC;
  115. case IDC_OCT:
  116. return CALC_SCI_OCT;
  117. case IDC_BIN:
  118. return CALC_SCI_BIN;
  119. case IDC_DEG:
  120. return CALC_SCI_DEG;
  121. case IDC_RAD:
  122. return CALC_SCI_RAD;
  123. case IDC_GRAD:
  124. return CALC_SCI_GRAD;
  125. case IDC_QWORD:
  126. return CALC_SCI_QWORD;
  127. case IDC_DWORD:
  128. return CALC_SCI_DWORD;
  129. case IDC_WORD:
  130. return CALC_SCI_WORD;
  131. case IDC_BYTE:
  132. return CALC_SCI_BYTE;
  133. case IDC_INV:
  134. return CALC_SCI_INV;
  135. case IDC_HYP:
  136. return CALC_SCI_HYP;
  137. case IDC_DISPLAY:
  138. return CALC_STD_VALUE;
  139. case IDC_MEMTEXT:
  140. return CALC_SCI_MEM;
  141. case IDC_PARTEXT:
  142. return CALC_SCI_PARENS;
  143. }
  144. ASSERT( 0 ); // an invalid help ID has been used.
  145. return 0;
  146. }
  147. /*
  148. BOOL IsUnaryOperator( int iID )
  149. {
  150. ASSERT( IsValidID( iID ) );
  151. return keys[INDEXFROMID(iID)].bUnary;
  152. }
  153. BOOL IsBinaryOperator( int iID )
  154. {
  155. ASSERT( IsValidID( iID ) );
  156. return keys[INDEXFROMID(iID)].bBinary;
  157. }
  158. BOOL UsesInvKey( int iID )
  159. {
  160. ASSERT( IsValidID( iID ) );
  161. return keys[INDEXFROMID(iID)].bUseInv;
  162. }
  163. BOOL UsesHypKey( int iID )
  164. {
  165. ASSERT( IsValidID( iID ) );
  166. return keys[INDEXFROMID(iID)].bUseHyp;
  167. }
  168. */