home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mnth0109.zip / Timur / menu.c < prev    next >
Text File  |  1993-06-07  |  2KB  |  80 lines

  1. /* MENU.C - Menu control functions
  2.  
  3. Copyright (c) 1992-1993 Timur Tabi
  4. Copyright (c) 1992-1993 Fasa Corporation
  5.  
  6. The following trademarks are the property of Fasa Corporation:
  7. BattleTech, CityTech, AeroTech, MechWarrior, BattleMech, and 'Mech.
  8. The use of these trademarks should not be construed as a challenge to these marks.
  9.  
  10. This module handles all the menu-related functions.
  11. */
  12.  
  13. #define INCL_WINDIALOGS
  14. #define INCL_WINMESSAGEMGR
  15. #define INCL_WINMENUS
  16. #include <os2.h>
  17.  
  18. #define MENU_C
  19.  
  20. #include "header.h"
  21. #include "window.h"
  22. #include "errors.h"
  23. #include "resource.h"
  24. #include "dialog.h"
  25. #include "menu.h"
  26. #include "files.h"
  27. #include "terrain.h"
  28.  
  29. MRESULT EXPENTRY AboutDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
  30.   if (msg == WM_COMMAND && SHORT1FROMMP(mp1) == DID_OK) {
  31.     WinDismissDlg(hwnd,TRUE);
  32.     return 0;
  33.   }
  34.   return WinDefDlgProc(hwnd,msg,mp1,mp2);
  35. }
  36.  
  37. void MainCommand(int iCmd) {
  38. /* Processes all the pull-down menu options.
  39. */
  40.   int i;
  41.   static USHORT usCurTer=IDM_TER_CLEAR_GROUND;
  42.  
  43. // First check the Terrain menu
  44.   if ((iCmd>=IDM_TERRAIN) && iCmd<(IDM_TERRAIN+100) ) {
  45.     for (i=0; i<NUM_TERRAINS; i++)
  46.       if (ater[i].iMenuID==iCmd) {
  47.         iCurTer=i;
  48.         WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(usCurTer,TRUE),MPFROM2SHORT(MIA_CHECKED,0));
  49.         usCurTer=(USHORT) iCmd;
  50.         WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(usCurTer,TRUE),MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  51.         }
  52.     return;
  53.   }
  54.  
  55. // Check the other menus
  56.   switch (iCmd) {
  57.     case IDM_ABOUT:
  58.       WinDlgBox(HWND_DESKTOP,hwndFrame,AboutDlgProc,NULLHANDLE,IDD_ABOUT,NULL);
  59.       break;
  60.     case IDM_FILE_OPEN:
  61.       TerrainOpenMap();
  62.       break;
  63.     case IDM_FILE_SAVE:
  64.       TerrainSaveMap();
  65.       break;
  66.     case IDM_FILE_SAVE_AS:
  67.       TerrainSaveMapAs();
  68.       break;
  69.     case IDM_FILE_QUIT:
  70.       WinSendMsg(hwndClient,WM_CLOSE,0L,0L);
  71.       break;
  72.     case IDM_MODE_MOVE:
  73.     case IDM_MODE_EDIT:
  74.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(iMode,TRUE),MPFROM2SHORT(MIA_CHECKED,0));
  75.       iMode=iCmd;
  76.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(iMode,TRUE),MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  77.       break;
  78.   }
  79. }
  80.