home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / gik2 / ewyio2eu.d2x / EWYEAAH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-04  |  10.0 KB  |  204 lines

  1. /*
  2. GIK/2 1.0.1 EWYEAAH.C 5621-432 (C) COPYRIGHT IBM CORP 1991, 1993.  ALL RIGHTS RESERVED.  LICENSED MATERIALS - PROPERTY OF IBM.
  3. */
  4. /**********************************************************************/
  5. /*                                                                    */
  6. /*                         MODULE PROLOGUE                            */
  7. /*                                                                    */
  8. /* COMPONENT NAME:   Data Flow Diagram (DFD) Example                  */
  9. /*                                                                    */
  10. /* MODULE NAME:      EWYEAAH.C                                        */
  11. /*                                                                    */
  12. /* DESCRIPTIVE NAME: Action handler function                          */
  13. /*                                                                    */
  14. /* PURPOSE:                                                           */
  15. /*                                                                    */
  16. /*   This module contains the action handling function for the        */
  17. /*   DFD example.                                                     */
  18. /*                                                                    */
  19. /* COPYRIGHT:        (C) 1991, 1993 IBM Corporation                   */
  20. /*                                                                    */
  21. /* DISCLAIMER OF WARRANTIES.  The following [enclosed] code is        */
  22. /* sample code created by IBM Corporation. This sample code is not    */
  23. /* part of any standard or IBM product and is provided to you solely  */
  24. /* for the purpose of assisting you in the development of your        */
  25. /* applications.  The code is provided "AS IS", without               */
  26. /* warranty of any kind.  IBM shall not be liable for any damages     */
  27. /* arising out of your use of the sample code, even if they have been */
  28. /* advised of the possibility of such damages.                        */
  29. /**********************************************************************/
  30.  
  31. /*--------------------------------------------------------------------*/
  32. /* INCLUDE RELATED DEFINES                                            */
  33. /*--------------------------------------------------------------------*/
  34.  
  35. #define  INCL_DOS                      /* OS/2 definitions            */
  36. #define  INCL_PM                       /* PM definitions              */
  37.  
  38. /*--------------------------------------------------------------------*/
  39. /* HEADER FILES                                                       */
  40. /*--------------------------------------------------------------------*/
  41.  
  42. #include <os2.h>                       /* OS/2 header file            */
  43. #include <ewyga.h>                     /* GIK/2 header file           */
  44. #include "ewyeadf.h"                   /* Generated header file       */
  45. #include <string.h>                    /* 'C' string handling         */
  46. #include "ewyearc.h"                   /* Dialog constants header     */
  47. #include "ewyea.h"                     /* Header shared with RC-file  */
  48.  
  49. /*--------------------------------------------------------------------*/
  50. /* LOCAL FUNCTION PROTOTYPES                                          */
  51. /*--------------------------------------------------------------------*/
  52.  
  53. SHORT GSENTRY ActionHandler(DHND,USHORT,MPARAM,MPARAM);
  54.  
  55. /**********************************************************************/
  56. /* ActionHandler                                                      */
  57. /*                                                                    */
  58. /* Parameters:                                                        */
  59. /*    DHND      dhnd      (I):    Diagram handle.                     */
  60. /*    USHORT    menu_id   (I):    Action selected by user.            */
  61. /*    MPARAM    mparam1   (I):    PM-data.                            */
  62. /*    MPARAM    mparam2   (I):    PM-data.                            */
  63. /*                                                                    */
  64. /* Returns:                                                           */
  65. /*    GS_OK                                                           */
  66. /*                                                                    */
  67. /* Description:                                                       */
  68. /*    The function handles all non-generic actions.                   */
  69. /**********************************************************************/
  70.  
  71. SHORT GSENTRY ActionHandler(DHND dhnd,USHORT menu_id,MPARAM mparam1,
  72.                              MPARAM mparam2)
  73. {
  74.   PTOOLDATA        pRefToolData;      // ptr to appl. data structure
  75.   PTOOLDATA        pToolData;         // ptr to appl. data structure
  76.   SHND             shnd;               // symbol handle
  77.   DLG_DATA         DlgData;            // symbol data
  78.   HWND             hWndC;              // client window handle
  79.  
  80.   switch (menu_id)
  81.   {
  82.     case  AH_SAVE :                    /* ~Save                       */
  83.  
  84.       /*--------------------------------------------------------------*/
  85.       /* Reset dhll links to data flow                                */
  86.       /*--------------------------------------------------------------*/
  87.  
  88.       GsCollectSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST);
  89.       while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
  90.         GsPutSymForm(dhnd, shnd, F_DATAFLOW);
  91.       if (GsTriggerGenericAction(dhnd, GE_SAVE, NULL) == GS_OK)
  92.         DefineRefinement(dhnd);
  93.       break;
  94. //
  95.     case  AH_SAVE_AS :                 /* Save ~as...                 */
  96.       if (GsTriggerGenericAction(dhnd, GE_SAVE_AS, NULL) == GS_OK)
  97.         DefineRefinement(dhnd);
  98.       break;
  99.     case  AH_CONTROLFLOW :             /* Co~ntrol Flow               */
  100.  
  101.       /*--------------------------------------------------------------*/
  102.       /* Change all links to control flow                             */
  103.       /*--------------------------------------------------------------*/
  104.  
  105.       GsCollectSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST);
  106.       while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
  107.         GsPutSymForm(dhnd, shnd, F_CONTROLFLOW);
  108.       break;
  109. //
  110.     case  AH_DATAFLOW :                /* D~ata Flow                  */
  111.  
  112.       /*--------------------------------------------------------------*/
  113.       /* Change all links to data flow                                */
  114.       /*--------------------------------------------------------------*/
  115.  
  116.       GsCollectSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST);
  117.       while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
  118.         GsPutSymForm(dhnd, shnd, F_DATAFLOW);
  119.       break;
  120. //
  121.     case  AH_REFINE :                  /* R~efine                     */
  122.  
  123.       /*--------------------------------------------------------------*/
  124.       /* This action is only available if and only if one function    */
  125.       /* symbol is selected.                                          */
  126.       /*--------------------------------------------------------------*/
  127.  
  128.       GsGetFirstSym(dhnd, GS_NODE, GS_SYM_SELECTED, GS_UPPER_FIRST,
  129.          &shnd);
  130.  
  131.       /*--------------------------------------------------------------*/
  132.       /* Prepare the parameters.                                      */
  133.       /*--------------------------------------------------------------*/
  134.  
  135.       pToolData = NULL;
  136.       GsGetDiagPointerN(dhnd, PTOOLDATA_ID, (PVOID *)&pToolData);
  137.       pToolData->dhnd = dhnd;          // diagram handle
  138.       pToolData->shnd = shnd;          // symbol handle
  139.  
  140.       /*--------------------------------------------------------------*/
  141.       /* Get the data from the object data buffer and check if the    */
  142.       /* file specification of a diagram was specified.               */
  143.       /*--------------------------------------------------------------*/
  144.  
  145.       GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
  146.       GsGetHwnd(dhnd, GS_WIN_MAIN, 0, FID_CLIENT, &hWndC); // get client handle
  147. //
  148.       if (strlen(DlgData.szRefDiag) > 0) // refinement exists ?
  149.         PerformRefinement(dhnd, shnd);
  150.       else
  151.       if (WinDlgBox(HWND_DESKTOP,      // Display the refinement
  152.          hWndC,                        // dialog. This allows the
  153.          SAMPLE_RefDlgProc,            // user to specify an
  154.          pToolData->hResModule,        // existing diagram.
  155.          DID_REF,                      //
  156.          (PVOID)pToolData))
  157.         PerformRefinement(dhnd, shnd);
  158.       break;
  159. //
  160.     case  AH_UNREFINE :                /* ~Unrefine                   */
  161.  
  162.       /*--------------------------------------------------------------*/
  163.       /* This action is only available if and only if one function    */
  164.       /* symbol is selected.                                          */
  165.       /*--------------------------------------------------------------*/
  166.  
  167.       GsGetFirstSym(dhnd, GS_NODE, GS_SYM_SELECTED, GS_UPPER_FIRST,
  168.          &shnd);
  169.  
  170.       /*--------------------------------------------------------------*/
  171.       /* Get the data from the object data buffer and check if a      */
  172.       /* refinement diagram exists. If yes, reinitialize the pointer  */
  173.       /* to this instance and the selected symbol.                    */
  174.       /*--------------------------------------------------------------*/
  175.  
  176.       GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
  177. //
  178.       if (DlgData.dhndRef)
  179.       {
  180.         pRefToolData = NULL;
  181.         GsGetDiagPointerN(DlgData.dhndRef, PTOOLDATA_ID,  //
  182.            (PVOID *)&pRefToolData);
  183.         pRefToolData->dhndPar = (DHND)0L;
  184.         pRefToolData->shndPar = (SHND)0L;
  185.       }
  186.  
  187.       /*--------------------------------------------------------------*/
  188.       /* Reinitialize the refinement data of the selected symbol.     */
  189.       /*--------------------------------------------------------------*/
  190.  
  191.       DlgData.dhndRef = 0L;
  192.       DlgData.szRefDiag[0] = '\0';
  193.       GsPutSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
  194. //
  195.       GsPutPartVisibility(dhnd, shnd, FN_REFINEMENT, GS_OFF);
  196.       break;
  197. //
  198.     default  :
  199.       break;
  200. //
  201.   }
  202.   return  GS_OK;
  203. }
  204.