home *** CD-ROM | disk | FTP | other *** search
- /*
- GIK/2 1.0.1 EWYEAAH.C 5621-432 (C) COPYRIGHT IBM CORP 1991, 1993. ALL RIGHTS RESERVED. LICENSED MATERIALS - PROPERTY OF IBM.
- */
- /**********************************************************************/
- /* */
- /* MODULE PROLOGUE */
- /* */
- /* COMPONENT NAME: Data Flow Diagram (DFD) Example */
- /* */
- /* MODULE NAME: EWYEAAH.C */
- /* */
- /* DESCRIPTIVE NAME: Action handler function */
- /* */
- /* PURPOSE: */
- /* */
- /* This module contains the action handling function for the */
- /* DFD example. */
- /* */
- /* COPYRIGHT: (C) 1991, 1993 IBM Corporation */
- /* */
- /* DISCLAIMER OF WARRANTIES. The following [enclosed] code is */
- /* sample code created by IBM Corporation. This sample code is not */
- /* part of any standard or IBM product and is provided to you solely */
- /* for the purpose of assisting you in the development of your */
- /* applications. The code is provided "AS IS", without */
- /* warranty of any kind. IBM shall not be liable for any damages */
- /* arising out of your use of the sample code, even if they have been */
- /* advised of the possibility of such damages. */
- /**********************************************************************/
-
- /*--------------------------------------------------------------------*/
- /* INCLUDE RELATED DEFINES */
- /*--------------------------------------------------------------------*/
-
- #define INCL_DOS /* OS/2 definitions */
- #define INCL_PM /* PM definitions */
-
- /*--------------------------------------------------------------------*/
- /* HEADER FILES */
- /*--------------------------------------------------------------------*/
-
- #include <os2.h> /* OS/2 header file */
- #include <ewyga.h> /* GIK/2 header file */
- #include "ewyeadf.h" /* Generated header file */
- #include <string.h> /* 'C' string handling */
- #include "ewyearc.h" /* Dialog constants header */
- #include "ewyea.h" /* Header shared with RC-file */
-
- /*--------------------------------------------------------------------*/
- /* LOCAL FUNCTION PROTOTYPES */
- /*--------------------------------------------------------------------*/
-
- SHORT GSENTRY ActionHandler(DHND,USHORT,MPARAM,MPARAM);
-
- /**********************************************************************/
- /* ActionHandler */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* USHORT menu_id (I): Action selected by user. */
- /* MPARAM mparam1 (I): PM-data. */
- /* MPARAM mparam2 (I): PM-data. */
- /* */
- /* Returns: */
- /* GS_OK */
- /* */
- /* Description: */
- /* The function handles all non-generic actions. */
- /**********************************************************************/
-
- SHORT GSENTRY ActionHandler(DHND dhnd,USHORT menu_id,MPARAM mparam1,
- MPARAM mparam2)
- {
- PTOOLDATA pRefToolData; // ptr to appl. data structure
- PTOOLDATA pToolData; // ptr to appl. data structure
- SHND shnd; // symbol handle
- DLG_DATA DlgData; // symbol data
- HWND hWndC; // client window handle
-
- switch (menu_id)
- {
- case AH_SAVE : /* ~Save */
-
- /*--------------------------------------------------------------*/
- /* Reset dhll links to data flow */
- /*--------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
- GsPutSymForm(dhnd, shnd, F_DATAFLOW);
- if (GsTriggerGenericAction(dhnd, GE_SAVE, NULL) == GS_OK)
- DefineRefinement(dhnd);
- break;
- //
- case AH_SAVE_AS : /* Save ~as... */
- if (GsTriggerGenericAction(dhnd, GE_SAVE_AS, NULL) == GS_OK)
- DefineRefinement(dhnd);
- break;
- case AH_CONTROLFLOW : /* Co~ntrol Flow */
-
- /*--------------------------------------------------------------*/
- /* Change all links to control flow */
- /*--------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
- GsPutSymForm(dhnd, shnd, F_CONTROLFLOW);
- break;
- //
- case AH_DATAFLOW : /* D~ata Flow */
-
- /*--------------------------------------------------------------*/
- /* Change all links to data flow */
- /*--------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_LINK, GS_SYM_SELECTED, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) != GSE_COLLECTION_EMPTY)
- GsPutSymForm(dhnd, shnd, F_DATAFLOW);
- break;
- //
- case AH_REFINE : /* R~efine */
-
- /*--------------------------------------------------------------*/
- /* This action is only available if and only if one function */
- /* symbol is selected. */
- /*--------------------------------------------------------------*/
-
- GsGetFirstSym(dhnd, GS_NODE, GS_SYM_SELECTED, GS_UPPER_FIRST,
- &shnd);
-
- /*--------------------------------------------------------------*/
- /* Prepare the parameters. */
- /*--------------------------------------------------------------*/
-
- pToolData = NULL;
- GsGetDiagPointerN(dhnd, PTOOLDATA_ID, (PVOID *)&pToolData);
- pToolData->dhnd = dhnd; // diagram handle
- pToolData->shnd = shnd; // symbol handle
-
- /*--------------------------------------------------------------*/
- /* Get the data from the object data buffer and check if the */
- /* file specification of a diagram was specified. */
- /*--------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
- GsGetHwnd(dhnd, GS_WIN_MAIN, 0, FID_CLIENT, &hWndC); // get client handle
- //
- if (strlen(DlgData.szRefDiag) > 0) // refinement exists ?
- PerformRefinement(dhnd, shnd);
- else
- if (WinDlgBox(HWND_DESKTOP, // Display the refinement
- hWndC, // dialog. This allows the
- SAMPLE_RefDlgProc, // user to specify an
- pToolData->hResModule, // existing diagram.
- DID_REF, //
- (PVOID)pToolData))
- PerformRefinement(dhnd, shnd);
- break;
- //
- case AH_UNREFINE : /* ~Unrefine */
-
- /*--------------------------------------------------------------*/
- /* This action is only available if and only if one function */
- /* symbol is selected. */
- /*--------------------------------------------------------------*/
-
- GsGetFirstSym(dhnd, GS_NODE, GS_SYM_SELECTED, GS_UPPER_FIRST,
- &shnd);
-
- /*--------------------------------------------------------------*/
- /* Get the data from the object data buffer and check if a */
- /* refinement diagram exists. If yes, reinitialize the pointer */
- /* to this instance and the selected symbol. */
- /*--------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
- //
- if (DlgData.dhndRef)
- {
- pRefToolData = NULL;
- GsGetDiagPointerN(DlgData.dhndRef, PTOOLDATA_ID, //
- (PVOID *)&pRefToolData);
- pRefToolData->dhndPar = (DHND)0L;
- pRefToolData->shndPar = (SHND)0L;
- }
-
- /*--------------------------------------------------------------*/
- /* Reinitialize the refinement data of the selected symbol. */
- /*--------------------------------------------------------------*/
-
- DlgData.dhndRef = 0L;
- DlgData.szRefDiag[0] = '\0';
- GsPutSymObjectData(dhnd, shnd, &DlgData, sizeof(DLG_DATA));
- //
- GsPutPartVisibility(dhnd, shnd, FN_REFINEMENT, GS_OFF);
- break;
- //
- default :
- break;
- //
- }
- return GS_OK;
- }