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

  1. /* MENU.C - Menu control functions
  2.  
  3. Copyright (c) 1993 Timur Tabi
  4. Copyright (c) 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 "resource.h"
  23. #include "dialog.h"
  24. #include "menu.h"
  25. #include "files.h"
  26. #include "terrain.h"
  27.  
  28. MRESULT EXPENTRY AboutDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
  29.   if (msg == WM_COMMAND && SHORT1FROMMP(mp1) == DID_OK) {
  30.     WinDismissDlg(hwnd,TRUE);
  31.     return 0;
  32.   }
  33.   return WinDefDlgProc(hwnd,msg,mp1,mp2);
  34. }
  35.  
  36. void MainCommand(USHORT usCmd) {
  37. /* Processes all the pull-down menu options.
  38.    Future enhancement: accelerator keys
  39. */
  40.   int i,iCmd=usCmd;                             // ints are more efficient than shorts
  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=usCmd;
  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_LOAD:
  61.       LoadMap(hwndFrame);
  62. // Now show the new map.
  63.       WinInvalidateRect(hwndClient,NULL,FALSE);   // Make sure the old map is erased
  64.       WinPostMsg(hwndClient,WM_PAINT,0,0);        // Draws the new map
  65.       break;
  66.     case IDM_FILE_SAVE_AS:
  67.       SaveMap(hwndFrame);
  68.       break;
  69.     case IDM_MODE_MOVE:
  70.     case IDM_MODE_EDIT:
  71.     case IDM_MODE_TARGET:
  72.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(iMode,TRUE),MPFROM2SHORT(MIA_CHECKED,0));
  73.       iMode=iCmd;
  74.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(iMode,TRUE),MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  75.       break;
  76.   }
  77. }
  78.