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.

273 lines
9.1 KiB

  1. #include "sol.h"
  2. #include <htmlhelp.h>
  3. VSZASSERT
  4. #define dxBord 3
  5. #define dyBord 3
  6. INT_PTR APIENTRY OptionsDlgProc(HANDLE hdlg, UINT wm, WPARAM wParam, LPARAM lParam)
  7. {
  8. BOOL fNewGame;
  9. static INT ccrdDealNew;
  10. static SMD smdNew;
  11. BOOL FDestroyStat();
  12. // Used for context sensitive help.
  13. static DWORD aIds[] = {
  14. ideDrawOne, IDH_OPTIONS_DRAW,
  15. ideDrawThree, IDH_OPTIONS_DRAW,
  16. ideScoreStandard, IDH_OPTIONS_SCORING,
  17. ideScoreVegas, IDH_OPTIONS_SCORING,
  18. ideScoreNone, IDH_OPTIONS_SCORING,
  19. ideTimedGame, IDH_OPTIONS_TIMED_GAME,
  20. ideStatusBar, IDH_OPTIONS_STATUS_BAR,
  21. ideOutlineDrag, IDH_OPTIONS_OUTLINE_DRAGGING,
  22. ideKeepScore, IDH_OPTIONS_CUMULATIVE_SCORE,
  23. ideScore, IDH_OPTIONS_CUMULATIVE_SCORE,
  24. 0,0 };
  25. switch(wm)
  26. {
  27. default:
  28. return fFalse;
  29. case WM_INITDIALOG:
  30. CheckRadioButton(hdlg, ideScoreStandard, ideScoreNone, smdNew = smd);
  31. ccrdDealNew = ccrdDeal;
  32. CheckRadioButton(hdlg, ideDrawOne, ideDrawThree, ccrdDeal == 1 ? ideDrawOne : ideDrawThree);
  33. CheckDlgButton(hdlg, ideStatusBar, (WORD)fStatusBar);
  34. CheckDlgButton(hdlg, ideTimedGame, (WORD)fTimedGame);
  35. CheckDlgButton(hdlg, ideOutlineDrag, (WORD)fOutlineDrag);
  36. CheckDlgButton(hdlg, ideKeepScore, (WORD)fKeepScore);
  37. EnableWindow(GetDlgItem(hdlg, ideKeepScore), smd == smdVegas);
  38. EnableWindow(GetDlgItem(hdlg, ideScore), smd == smdVegas);
  39. break;
  40. case WM_COMMAND:
  41. switch( GET_WM_COMMAND_ID( wParam, lParam) )
  42. {
  43. default:
  44. return fFalse;
  45. case ideDrawOne:
  46. case ideDrawThree:
  47. ccrdDealNew = GET_WM_COMMAND_ID( wParam, lParam) == ideDrawOne ? 1 : 3;
  48. CheckRadioButton(hdlg, ideDrawOne, ideDrawThree, GET_WM_COMMAND_ID( wParam, lParam));
  49. break;
  50. case ideScoreStandard:
  51. case ideScoreVegas:
  52. case ideScoreNone:
  53. smdNew = GET_WM_COMMAND_ID( wParam, lParam );
  54. CheckRadioButton(hdlg, ideScoreStandard, ideScoreNone, GET_WM_COMMAND_ID( wParam, lParam ));
  55. EnableWindow(GetDlgItem(hdlg, ideKeepScore), smdNew == smdVegas);
  56. EnableWindow(GetDlgItem(hdlg, ideScore), smdNew == smdVegas);
  57. break;
  58. case IDOK:
  59. fNewGame = fFalse;
  60. if(IsDlgButtonChecked(hdlg, ideStatusBar) != (WORD)fStatusBar)
  61. {
  62. if(fStatusBar ^= 1)
  63. FCreateStat();
  64. else
  65. FDestroyStat();
  66. }
  67. if(ccrdDealNew != ccrdDeal)
  68. {
  69. ccrdDeal = ccrdDealNew;
  70. FInitGm();
  71. PositionCols();
  72. fNewGame = fTrue;
  73. }
  74. if(IsDlgButtonChecked(hdlg, ideTimedGame) != (WORD)fTimedGame)
  75. {
  76. fTimedGame ^= 1;
  77. fNewGame = fTrue;
  78. }
  79. if(smd != smdNew)
  80. {
  81. smd = smdNew;
  82. fNewGame = fTrue;
  83. }
  84. if(IsDlgButtonChecked(hdlg, ideOutlineDrag) != (WORD)fOutlineDrag)
  85. {
  86. FSetDrag(fOutlineDrag^1);
  87. }
  88. fKeepScore = IsDlgButtonChecked(hdlg, ideKeepScore);
  89. WriteIniFlags(wifOpts|wifBitmap);
  90. /* fall thru */
  91. case IDCANCEL:
  92. EndDialog(hdlg, GET_WM_COMMAND_ID( wParam, lParam ) == IDOK && fNewGame);
  93. break;
  94. }
  95. break;
  96. // context sensitive help.
  97. case WM_HELP:
  98. WinHelp(((LPHELPINFO) lParam)->hItemHandle, TEXT("sol.hlp"),
  99. HELP_WM_HELP, (ULONG_PTR) aIds);
  100. break;
  101. case WM_CONTEXTMENU:
  102. WinHelp((HWND) wParam, TEXT("sol.hlp"), HELP_CONTEXTMENU,
  103. (ULONG_PTR) aIds);
  104. break;
  105. }
  106. return fTrue;
  107. }
  108. VOID DoOptions()
  109. {
  110. BOOL fNewGame;
  111. if(fNewGame = (BOOL)DialogBox(hinstApp,
  112. MAKEINTRESOURCE(iddOptions),
  113. hwndApp,
  114. OptionsDlgProc))
  115. NewGame(fTrue, fTrue);
  116. }
  117. BOOL FDrawFocus(HDC hdc, RC *prc, BOOL fFocus)
  118. {
  119. HBRUSH hbr;
  120. RC rc;
  121. hbr = CreateSolidBrush(GetSysColor(fFocus ? COLOR_HIGHLIGHT : COLOR_3DFACE));
  122. if(hbr == NULL)
  123. return fFalse;
  124. rc = *prc;
  125. FrameRect(hdc, (LPRECT) &rc, hbr);
  126. InflateRect((LPRECT) &rc, -1, -1);
  127. FrameRect(hdc, (LPRECT) &rc, hbr);
  128. DeleteObject(hbr);
  129. return fTrue;
  130. }
  131. INT_PTR APIENTRY BackDlgProc(HANDLE hdlg, UINT wm, WPARAM wParam, LPARAM lParam)
  132. {
  133. static INT modeNew;
  134. MEASUREITEMSTRUCT FAR *lpmi;
  135. DRAWITEMSTRUCT FAR *lpdi;
  136. RC rc, rcCrd;
  137. HDC hdc;
  138. // Used for context sensitive help.
  139. static DWORD aIds[] = {
  140. IDFACEDOWN1, IDH_SELECT_CARD_BACK,
  141. IDFACEDOWN2, IDH_SELECT_CARD_BACK,
  142. IDFACEDOWN3, IDH_SELECT_CARD_BACK,
  143. IDFACEDOWN4, IDH_SELECT_CARD_BACK,
  144. IDFACEDOWN5, IDH_SELECT_CARD_BACK,
  145. IDFACEDOWN6, IDH_SELECT_CARD_BACK,
  146. IDFACEDOWN7, IDH_SELECT_CARD_BACK,
  147. IDFACEDOWN8, IDH_SELECT_CARD_BACK,
  148. IDFACEDOWN9, IDH_SELECT_CARD_BACK,
  149. IDFACEDOWN10, IDH_SELECT_CARD_BACK,
  150. IDFACEDOWN11, IDH_SELECT_CARD_BACK,
  151. IDFACEDOWN12, IDH_SELECT_CARD_BACK,
  152. 0,0 };
  153. switch(wm)
  154. {
  155. case WM_INITDIALOG:
  156. modeNew = modeFaceDown;
  157. SetFocus(GetDlgItem(hdlg, modeFaceDown));
  158. return fFalse;
  159. case WM_COMMAND:
  160. if( GET_WM_COMMAND_CMD( wParam, lParam )==BN_CLICKED )
  161. if( GET_WM_COMMAND_ID( wParam, lParam ) >= IDFACEDOWNFIRST && GET_WM_COMMAND_ID( wParam, lParam ) <= IDFACEDOWN12) {
  162. modeNew = (INT) wParam;
  163. break;
  164. }
  165. if( GET_WM_COMMAND_CMD( wParam, lParam )==BN_DOUBLECLICKED )
  166. if( GET_WM_COMMAND_ID( wParam, lParam ) >= IDFACEDOWNFIRST && GET_WM_COMMAND_ID( wParam, lParam ) <= IDFACEDOWN12 )
  167. // BabakJ: On Win32, we are destroying wNotifyCode, but is not used later!
  168. wParam=IDOK;
  169. // slimy fall through hack of doom (no dupe code or goto)
  170. switch( GET_WM_COMMAND_ID( wParam, lParam )) {
  171. case IDOK:
  172. ChangeBack(modeNew);
  173. WriteIniFlags(wifBack);
  174. // fall thru
  175. case IDCANCEL:
  176. EndDialog(hdlg, 0);
  177. break;
  178. }
  179. break;
  180. case WM_MEASUREITEM:
  181. lpmi = (MEASUREITEMSTRUCT FAR *)lParam;
  182. lpmi->CtlType = ODT_BUTTON;
  183. lpmi->itemWidth = 32;
  184. lpmi->itemHeight = 54;
  185. break;
  186. case WM_DRAWITEM:
  187. lpdi = (DRAWITEMSTRUCT FAR *)lParam;
  188. CopyRect((LPRECT) &rc, &lpdi->rcItem);
  189. rcCrd = rc;
  190. InflateRect((LPRECT) &rcCrd, -dxBord, -dyBord);
  191. hdc = lpdi->hDC;
  192. if (lpdi->itemAction == ODA_DRAWENTIRE)
  193. {
  194. cdtDrawExt(hdc, rcCrd.xLeft, rcCrd.yTop,
  195. rcCrd.xRight-rcCrd.xLeft, rcCrd.yBot-rcCrd.yTop,
  196. lpdi->CtlID, FACEDOWN, 0L);
  197. FDrawFocus(hdc, &rc, lpdi->itemState & ODS_FOCUS);
  198. break;
  199. }
  200. if (lpdi->itemAction == ODA_SELECT)
  201. InvertRect(hdc, (LPRECT)&rcCrd);
  202. if (lpdi->itemAction == ODA_FOCUS) {
  203. // Set the new mode when we get focus
  204. if (lpdi->itemState & ODS_FOCUS)
  205. modeNew = lpdi->CtlID;
  206. FDrawFocus(hdc, &rc, lpdi->itemState & ODS_FOCUS);
  207. }
  208. break;
  209. // context sensitive help.
  210. case WM_HELP:
  211. WinHelp(((LPHELPINFO) lParam)->hItemHandle, TEXT("sol.hlp"),
  212. HELP_WM_HELP, (ULONG_PTR) aIds);
  213. break;
  214. case WM_CONTEXTMENU:
  215. WinHelp((HWND) wParam, TEXT("sol.hlp"), HELP_CONTEXTMENU,
  216. (ULONG_PTR) aIds);
  217. break;
  218. default:
  219. return fFalse;
  220. }
  221. return fTrue;
  222. }
  223. LRESULT APIENTRY BackPushProc(HWND hwnd, INT wm, WPARAM wParam, LPARAM lParam)
  224. {
  225. return 0L;
  226. }
  227. VOID DoBacks()
  228. {
  229. DialogBox(hinstApp,
  230. MAKEINTRESOURCE(iddBacks),
  231. hwndApp,
  232. BackDlgProc);
  233. }