home *** CD-ROM | disk | FTP | other *** search
- /*
- GIK/2 1.0.1 EWYQAEH.C 5621-432 (C) COPYRIGHT IBM CORP 1991, 1993. ALL RIGHTS RESERVED. LICENSED MATERIALS - PROPERTY OF IBM.
- */
- /**********************************************************************/
- /* */
- /* MODULE PROLOGUE */
- /* */
- /* COMPONENT NAME: PERSONNEL DATABASE EXAMPLE */
- /* */
- /* MODULE NAME: EWYQAEH.C */
- /* */
- /* DESCRIPTIVE NAME: Graphics Interface Kit/2 - */
- /* Personnel Database Example */
- /* */
- /* PURPOSE: Event functions */
- /* */
- /* 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 <string.h> /* C library header */
- #include <ewyga.h> /* GIK/2 header file */
- #include "EWYQADF.H" /* Generated header file */
- #include "EWYQA.H" /* Example header file */
-
- /*--------------------------------------------------------------------*/
- /* CONSTANTS */
- /*--------------------------------------------------------------------*/
- /* $$N */
- #define STR_REMOVE_EMPLOYEES \
- "Employees that are not selected will be removed.\
- Do you want to continue?"
- #define STR_PLACE_ADDED_EMPLOYEE \
- "You can only place the new employee on a manager"
- #define STR_PLACE_MOVED_EMPLOYEE \
- "You can only place the employee on a manager"
- #define STR_PLACE_1_MOVED_DEP_MANAGER \
- "You can only place employees that do not report \
- to a manager on a manager"
- #define STR_PLACE_N_MOVED_DEP_MANAGER \
- "You can only place an employee that does not \
- report to a manager on a manager"
-
- /*--------------------------------------------------------------------*/
- /* MACROS */
- /*--------------------------------------------------------------------*/
-
- #define MSG_EMPLOYEE_NOT_ATTACHED(str) \
- GsMessageBox(dhnd, str, "", MB_OK|MB_WARNING, NULL)
- /* $$F */
- /*--------------------------------------------------------------------*/
- /* LOCAL FUNCTION PROTOTYPES */
- /*--------------------------------------------------------------------*/
-
- SHORT GSENTRY EvActionDone(DHND,SHORT,EVS_ACTION_DONE *);
-
- SHORT GSENTRY EvClear(DHND,SHORT,VOID *);
- SHORT GSENTRY EvClick(DHND,SHORT,EVS_CLICK *);
- SHORT GSENTRY EvEndAdd(DHND,SHORT,EVS_END_ADD *);
- SHORT GSENTRY EvEndMove(DHND,SHORT,EVS_END_MOVE *);
- SHORT GSENTRY EvInit(DHND,SHORT,EVS_INIT *);
- SHORT GSENTRY EvMenu(DHND,SHORT,EVS_MENU *);
- SHORT GSENTRY EvNew(DHND,SHORT,VOID *);
- SHORT GSENTRY EvStartAdd(DHND,SHORT,EVS_START_ADD *);
- SHORT GSENTRY EvStartMove(DHND,SHORT,EVS_START_MOVE *);
- SHORT GSENTRY EvDragOver(DHND,SHORT,EVS_DRAG_OVER *);
- SHORT GSENTRY EvDrop(DHND,SHORT,EVS_DROP *);
- SHORT GSENTRY EvEndDrag(DHND,SHORT,EVS_END_DRAG *);
- SHORT GSENTRY EvStartDrag(DHND,SHORT,EVS_START_DRAG *);
-
- /*--------------------------------------------------------------------*/
- /* Auxiliary functions (local). */
- /*--------------------------------------------------------------------*/
-
- static VOID PerformLayout(DHND);
- SHORT AllSubtreeEmployeeAf(DHND);
- static VOID PutAllSubtreeSymAf(DHND,SHND,BOOL);
- static VOID RemoveEmployee(DHND,SHND);
- static VOID RemoveGenManager(DHND);
- SHORT ManagerAfOff(DHND,SHND);
- static VOID DeleteLink(DHND,SHND);
- static VOID RemoveManager(DHND,SHND);
- SHORT SetGenManager(DHND);
- SHORT EmployeeForGenManager(DHND,SHND);
- SHORT AttachMoveEmployeeToManager(DHND,SHND);
- SHORT AttachEmployeeToManager(DHND,SHND,SHND);
- SHORT AllVisibleEmployeesMoved(DHND);
- SHORT NotSelectedDepManager(DHND,SHND);
- SHORT VisibleEmployee(DHND);
- SHORT DeleteAllNewLinks(DHND);
- static VOID ShowMsgAfterMovingEmployees(DHND);
- SHORT SymDragged(DHND,DRAGINFO *);
- SHORT AllVisibleEmployeesDragged(DHND,DRAGINFO *);
- static VOID UpdateEmployeeData(DHND,DRAGINFO *,SHND);
- static VOID GetTargetNode(DHND,DRAGINFO *,SHND,SHND *);
- SHORT DropEmployeeForGenManager(DHND);
- SHORT AttachDrop1EmployeeToManager(DHND,POINTL);
- SHORT AttachDropNEmployeeToManager(DHND);
- static VOID PutAllLinkToPreManagerAf(DHND);
- static VOID PutLinkToPreManagerAf(DHND,SHND);
-
- /**********************************************************************/
- /* EvActionDone */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_ACTION_DONE *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHORT action_type (I): Type of action */
- /* It is one of the following: */
- /* GE_* */
- /* GI_* */
- /* GS_ACTION_HANDLER */
- /* USHORT menu_id (I): Identifier of the menu item in the */
- /* menu bar. It is 0 for Implicit */
- /* Actions and when a symbol is added */
- /* from the Symbol Palette. */
- /* SHORT action_rc (I): Return code of the Explicit Action,*/
- /* Implicit Action or User Action that*/
- /* takes place before the event is */
- /* triggered. */
- /* */
- /* */
- /* Returns: */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_ACTION_DONE. */
- /* - Performs a layout algorithm. */
- /**********************************************************************/
-
- SHORT GSENTRY EvActionDone(DHND dhnd,SHORT ev_id,EVS_ACTION_DONE *pEvs)
- {
- SHORT action_num; /* number of pending actions */
- GSS_ACTION action[GS_ACTION_num];/* action data */
- SHORT cnt; /* action count */
- BOOL drag; /* indicates whether GI_DRAG is
- being processed */
-
- /*------------------------------------------------------------------*/
- /* Handle the actions. */
- /*------------------------------------------------------------------*/
-
- switch (pEvs->action_type)
- {
- case GE_ADD_SYM :
- case GI_MOVE_BP_SYM :
-
- /*--------------------------------------------------------------*/
- /* Perform a layout algorithm. */
- /*--------------------------------------------------------------*/
-
- PerformLayout(dhnd);
- break;
- case GE_CLEAR :
-
- /*--------------------------------------------------------------*/
- /* If at least one symbol representing an employee in the */
- /* company is visible, perform a layout algorithm. */
- /*--------------------------------------------------------------*/
-
- if (VisibleEmployee(dhnd) == GS_YES)
- {
- PerformLayout(dhnd);
- }
- break;
- case GE_OPEN :
-
- /*--------------------------------------------------------------*/
- /* Determine the general manager. */
- /*--------------------------------------------------------------*/
-
- SetGenManager(dhnd);
- break;
- case GI_DRAG :
-
- /*--------------------------------------------------------------*/
- /* If the drag operation has been stopped, restore the previous */
- /* position of the symbols. Otherwise, perform a layout */
- /* algorithm. */
- /*--------------------------------------------------------------*/
-
- if (pEvs->action_rc != GS_OK)
- {
- GsTriggerGenericAction(dhnd, GE_UNDO, NULL);
- }
- else
- {
- PerformLayout(dhnd);
- }
-
- /*--------------------------------------------------------------*/
- /* Determine the general manager. */
- /*--------------------------------------------------------------*/
-
- SetGenManager(dhnd);
- break;
- case GI_DROP :
-
- /*--------------------------------------------------------------*/
- /* If the target window of the direct manipulation operation is */
- /* not the same as its source window, perform a layout */
- /* algorithm. */
- /*--------------------------------------------------------------*/
-
- GsGetAction(dhnd, NULL, &action_num);
- GsGetAction(dhnd, action, &action_num);
- for (drag = FALSE, cnt = action_num; (!drag) && (cnt >= 0); cnt--)
- {
- drag = (action[cnt].action_type == GI_DRAG);
- }
- if (!drag)
- {
- PerformLayout(dhnd);
- }
- break;
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* PerformLayout */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function performs a layout algorithm. */
- /**********************************************************************/
-
- static VOID PerformLayout(DHND dhnd)
- {
- SHORT action_num; /* number of pending actions */
-
- /*------------------------------------------------------------------*/
- /* If not more than one action is pending, a layout algorithm is */
- /* performed. */
- /*------------------------------------------------------------------*/
-
- GsGetAction(dhnd, NULL, &action_num);
- if (action_num <= 1)
- {
- GsTriggerGenericAction(dhnd, GE_LAYOUT, NULL);
- }
- }
-
- /**********************************************************************/
- /* EvClear */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* VOID *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_CLEAR. */
- /* - Checks whether a subtree with more than one employee is to be */
- /* deleted. */
- /* - All selected node symbols and their children are marked for */
- /* deletion. */
- /**********************************************************************/
-
- SHORT GSENTRY EvClear(DHND dhnd,SHORT ev_id,VOID *pEvs)
- {
- SHND employee_shnd; /* handle of employee */
- USHORT button; /* push-button clicked on */
-
- /*------------------------------------------------------------------*/
- /* If a subtree with symbols that are not selected is to be deleted,*/
- /* a message is displayed to inform the end user. */
- /*------------------------------------------------------------------*/
-
- if (AllSubtreeEmployeeAf(dhnd) == GS_NO)
- {
- GsMessageBox(dhnd, STR_REMOVE_EMPLOYEES, "", MB_YESNO|MB_WARNING,
- &button);
- if (button != MBID_YES)
- {
- return GS_NO;
- }
- }
-
- /*------------------------------------------------------------------*/
- /* Mark symbols for deletion. All selected symbols representing */
- /* employees have the action flag already set. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
- PutAllSubtreeSymAf(dhnd, employee_shnd, FALSE);
- RemoveEmployee(dhnd, employee_shnd);
- }
-
- /*------------------------------------------------------------------*/
- /* If all employees are to be deleted, also the general manager has */
- /* to be removed from the company. */
- /*------------------------------------------------------------------*/
-
- RemoveGenManager(dhnd);
- return GS_YES;
- }
-
- /**********************************************************************/
- /* AllSubtreeEmployeeAf */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks for all symbols representing employees the */
- /* following: */
- /* - The symbol has its action flag set. */
- /* - The employee is a manager to whom employees are reporting. */
- /* - All symbols representing employees reporting to the manager */
- /* have their action flag set. */
- /**********************************************************************/
-
- SHORT AllSubtreeEmployeeAf(DHND dhnd)
- {
- SHND employee_shnd; /* handle of employee */
- EMPLOYEE employee; /* employee object data */
- SHORT af; /* state of the action flag */
- SHORT cnt; /* symbol count */
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols having their action flag set. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* Retrieve the employee data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*----------------------------------------------------------------*/
- /* Loop over all employees reporting to the current employee. */
- /*----------------------------------------------------------------*/
-
- for (cnt = 0; cnt < employee.employee_num; cnt++)
- {
-
- /*--------------------------------------------------------------*/
- /* See whether the symbol representing an employee has its */
- /* action flag set. */
- /*--------------------------------------------------------------*/
-
- GsGetSymAf(dhnd, employee.employee_shnd[cnt], &af);
- if (af == GS_OFF)
- {
- GsEndSymCollection(dhnd);
- return GS_NO;
- }
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* PutAllSubtreeSymAf */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND root_shnd (I): Handle of the root symbol of a */
- /* subtree */
- /* BOOL child (I): Indicates a recursive call */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function recursively sets the action flag of all symbols of */
- /* a subtree. */
- /**********************************************************************/
-
- static VOID PutAllSubtreeSymAf(DHND dhnd,SHND root_shnd,BOOL child)
- {
- SHND link_shnd; /* handle of link symbol */
- EMPLOYEE employee; /* employee object data */
- SHORT cnt; /* symbol count */
-
- /*------------------------------------------------------------------*/
- /* Set the action flag of the symbol. */
- /*------------------------------------------------------------------*/
-
- GsPutSymAf(dhnd, root_shnd, GS_ON);
-
- /*------------------------------------------------------------------*/
- /* Set the action flag of the link between symbol and its parent */
- /* symbol. */
- /*------------------------------------------------------------------*/
-
- if (child)
- {
- GsGetFirstAttachedSym(dhnd, GS_TARGET_ATTACHED_LINK, root_shnd,
- &link_shnd, NULL);
- GsPutSymAf(dhnd, link_shnd, GS_ON);
- }
-
- /*------------------------------------------------------------------*/
- /* Retrieve the data of the employee represented by the root symbol.*/
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, root_shnd, (PVOID)&employee, sizeof(employee)
- );
-
- /*------------------------------------------------------------------*/
- /* Set the action flag of all symbols of all subtrees that have the */
- /* root symbol as parent. */
- /*------------------------------------------------------------------*/
-
- for (cnt = 0; cnt < employee.employee_num; cnt++)
- {
- PutAllSubtreeSymAf(dhnd, employee.employee_shnd[cnt], TRUE);
- }
- }
-
- /**********************************************************************/
- /* RemoveEmployee */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function removes an employee from its manager. */
- /**********************************************************************/
-
- static VOID RemoveEmployee(DHND dhnd,SHND employee_shnd)
- {
- EMPLOYEE employee; /* employee object data */
- EMPLOYEE manager; /* manager object data */
- SHORT i; /* array index */
-
- /*------------------------------------------------------------------*/
- /* See whether the employee reports to a manager. */
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
- if (employee.manager_shnd != GS_INVALID_SHND)
- { /* the employee reports to a
- manager */
-
- /*----------------------------------------------------------------*/
- /* Retrieve the manager object data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee.manager_shnd, (PVOID)&manager,
- sizeof(manager));
-
- /*----------------------------------------------------------------*/
- /* Retrieve the index of the employee to be removed in the array */
- /* of employee handles. */
- /*----------------------------------------------------------------*/
-
- i = 0;
- while ((manager.employee_shnd[i] != employee_shnd) && (i <
- EMPLOYEE_MAX))
- {
- i++;
- }
-
- /*----------------------------------------------------------------*/
- /* See whether the index was found. */
- /*----------------------------------------------------------------*/
-
- if (i < EMPLOYEE_MAX)
- { /* correct index */
-
- /*--------------------------------------------------------------*/
- /* Reduce the number of employees reporting to the manager. */
- /*--------------------------------------------------------------*/
-
- manager.employee_num--;
-
- /*--------------------------------------------------------------*/
- /* Remove the handle of the employee from the array. */
- /*--------------------------------------------------------------*/
-
- memcpy(&manager.employee_shnd[i], &manager.employee_shnd[i+1],
- (manager.employee_num-i)*sizeof(SHND));
-
- /*--------------------------------------------------------------*/
- /* Store the manager object data. */
- /*--------------------------------------------------------------*/
-
- GsPutSymObjectData(dhnd, employee.manager_shnd, (PVOID)&manager,
- sizeof(manager));
- }
- }
- }
-
- /**********************************************************************/
- /* RemoveGenManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function removes the general manager from the company. */
- /**********************************************************************/
-
- static VOID RemoveGenManager(DHND dhnd)
- {
- SHND gen_manager_shnd; /* handle of general manager */
- SHORT af; /* state of the action flag */
- LONG long_value; /* long value of the diagram */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the general */
- /* manager. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagLong(dhnd, &long_value);
- gen_manager_shnd = LOUSHORT(long_value);
-
- /*------------------------------------------------------------------*/
- /* See whether the general manager is to be removed. This means that*/
- /* all employees are removed. */
- /*------------------------------------------------------------------*/
-
- GsGetSymAf(dhnd, gen_manager_shnd, &af);
- if (af == GS_ON)
- { /* the general manager is to be
- removed */
-
- /*----------------------------------------------------------------*/
- /* Store the handle of the symbol representing the general */
- /* manager. As there will be no employee in the company, the value*/
- /* being stored is GS_INVALID_SHND. */
- /*----------------------------------------------------------------*/
-
- GsPutDiagLong(dhnd, (LONG)GS_INVALID_SHND);
- }
- }
-
- /**********************************************************************/
- /* EvClick */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_CLICK *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHND shnd (I): Handle of the symbol */
- /* SHORT part_ref (I): Reference number of the symbol part*/
- /* USHORT button (I): indicator of the pressed mouse */
- /* button */
- /* GS_MB1 */
- /* GS_MB2 */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_CLICK. */
- /* - Flips the visibility state of the symbol part indicating the */
- /* sex of the employee. */
- /**********************************************************************/
-
- SHORT GSENTRY EvClick(DHND dhnd,SHORT ev_id,EVS_CLICK *pEvs)
- {
- SHORT visible;
-
- /*------------------------------------------------------------------*/
- /* See whether a woman is shown. */
- /*------------------------------------------------------------------*/
-
- GsGetPartVisibility(dhnd, pEvs->shnd, PERSON_WOMAN, &visible);
- if (visible == GS_ON)
- { /* a woman is shown */
-
- /*----------------------------------------------------------------*/
- /* Show a man. */
- /*----------------------------------------------------------------*/
-
- GsPutPartVisibility(dhnd, pEvs->shnd, PERSON_WOMAN, GS_OFF);
- GsPutPartVisibility(dhnd, pEvs->shnd, PERSON_MAN, GS_ON);
- }
- else
- { /* a man is shown */
-
- /*----------------------------------------------------------------*/
- /* Show a woman. */
- /*----------------------------------------------------------------*/
-
- GsPutPartVisibility(dhnd, pEvs->shnd, PERSON_WOMAN, GS_ON);
- GsPutPartVisibility(dhnd, pEvs->shnd, PERSON_MAN, GS_OFF);
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvEndAdd */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_END_ADD *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHND shnd (I): Handle of the symbol */
- /* POINTL mouse_pos (I): Position of the mouse pointer */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_END_ADD. */
- /* - The employee-manager relationship for the new employee is */
- /* determined. */
- /* - The data of the new employee are initialized. */
- /**********************************************************************/
-
- SHORT GSENTRY EvEndAdd(DHND dhnd,SHORT ev_id,EVS_END_ADD *pEvs)
- {
- EMPLOYEE employee; /* employee object data */
- SHORT rc; /* return code */
-
- /*------------------------------------------------------------------*/
- /* Initialize the employee data. */
- /*------------------------------------------------------------------*/
-
- memset(&employee, 0, sizeof(employee));
- GsPutSymObjectData(dhnd, pEvs->shnd, (PVOID)&employee, sizeof(employee
- ));
-
- /*------------------------------------------------------------------*/
- /* If the new employee will not become general manager, it is to be */
- /* attached to a manager. */
- /*------------------------------------------------------------------*/
-
- if (EmployeeForGenManager(dhnd, pEvs->shnd) == GS_NO)
- { /* the employee is not general
- manager */
- rc = AttachMoveEmployeeToManager(dhnd, pEvs->shnd);
- switch (rc)
- {
- case GS_YES :
- break;
- case GS_REJECT :
- MSG_EMPLOYEE_NOT_ATTACHED(STR_PLACE_ADDED_EMPLOYEE);
- return (rc);
- default :
- return GS_RESTORE;
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* SetGenManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function retrieves the general manager of a company and */
- /* stores this information. */
- /**********************************************************************/
-
- SHORT SetGenManager(DHND dhnd)
- {
- SHND gen_manager_shnd; /* handle of general manager */
- SHND employee_shnd; /* handle of employee */
- LONG long_value; /* long value of the diagram */
- EMPLOYEE employee; /* employee object data */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the general */
- /* manager. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagLong(dhnd, &long_value);
- gen_manager_shnd = LOUSHORT(long_value);
-
- /*------------------------------------------------------------------*/
- /* See whether a general manager exists. */
- /*------------------------------------------------------------------*/
-
- if (gen_manager_shnd == GS_INVALID_SHND)
- { /* no general manager exists */
-
- /*----------------------------------------------------------------*/
- /* See whether an employee exists. */
- /*----------------------------------------------------------------*/
-
- if (GsGetFirstSym(dhnd, GS_NODE, GS_ANY_SYM, GS_UPPER_FIRST,
- &employee_shnd) == GS_OK)
- { /* an employee exists */
- while (employee_shnd != GS_INVALID_SHND)
- {
-
- /*------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*------------------------------------------------------------*/
- /* See whether the employee is the general manager. */
- /*------------------------------------------------------------*/
-
- if (employee.manager_shnd == GS_INVALID_SHND)
- { /* he is the general manager */
- break;
- }
- else
- { /* he is not the general
- manager */
- employee_shnd = employee.manager_shnd;
- }
- }
-
- /*--------------------------------------------------------------*/
- /* The employee is stored as general manager. */
- /*--------------------------------------------------------------*/
-
- EmployeeForGenManager(dhnd, employee_shnd);
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EmployeeForGenManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks whether this is the first employee added */
- /* to the company. */
- /**********************************************************************/
-
- SHORT EmployeeForGenManager(DHND dhnd,SHND employee_shnd)
- {
- SHND gen_manager_shnd; /* handle of general manager */
- EMPLOYEE employee; /* employee object data */
- LONG long_value; /* long value of the diagram */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the general */
- /* manager. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagLong(dhnd, &long_value);
- gen_manager_shnd = LOUSHORT(long_value);
-
- /*------------------------------------------------------------------*/
- /* See whether a general manager exists. */
- /*------------------------------------------------------------------*/
-
- if (gen_manager_shnd == GS_INVALID_SHND)
- { /* no general manager exists */
-
- /*----------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*----------------------------------------------------------------*/
- /* The employee is stored as general manager. */
- /*----------------------------------------------------------------*/
-
- GsPutDiagLong(dhnd, (LONG)employee_shnd);
-
- /*----------------------------------------------------------------*/
- /* Store the information about the manager in the employee data. */
- /*----------------------------------------------------------------*/
-
- employee.manager_shnd = GS_INVALID_SHND;
- employee.pre_manager_shnd = GS_INVALID_SHND;
- GsPutSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
- return GS_YES;
- }
- return GS_NO;
- }
-
- /**********************************************************************/
- /* AttachMoveEmployeeToManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* GS_NO the attachment is not done */
- /* GS_REJECT the attachment is not accepted */
- /* GS_YES the attachment is done */
- /* */
- /* Description: */
- /* The function adds an employee to a manager. */
- /**********************************************************************/
-
- SHORT AttachMoveEmployeeToManager(DHND dhnd,SHND employee_shnd)
- {
- SHND manager_shnd; /* handle of manager */
-
- /*------------------------------------------------------------------*/
- /* Determine the manager of the employee. */
- /*------------------------------------------------------------------*/
-
- if (GsGetFirstOverlappedSym(dhnd, GS_NODE, GS_UPPER_FIRST,
- employee_shnd, 0, &manager_shnd, NULL) == GSE_COLLECTION_EMPTY)
- {
- return GS_REJECT;
- }
-
- /*------------------------------------------------------------------*/
- /* Define the employee-manager relationship. */
- /*------------------------------------------------------------------*/
-
- return AttachEmployeeToManager(dhnd, employee_shnd, manager_shnd);
- }
-
- /**********************************************************************/
- /* AttachEmployeeToManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* SHND manager_shnd (I): handle of manager */
- /* */
- /* Returns: */
- /* GS_NO the attachment is not done */
- /* GS_YES the attachment is done */
- /* */
- /* Description: */
- /* The function adds an employee to a manager. */
- /**********************************************************************/
-
- SHORT AttachEmployeeToManager(DHND dhnd,SHND employee_shnd,SHND
- manager_shnd)
- {
- SHND link_shnd; /* handle of link symbol */
- EMPLOYEE employee; /* employee object data */
- EMPLOYEE manager; /* manager object data */
-
- /*------------------------------------------------------------------*/
- /* Check the symbol handles. */
- /*------------------------------------------------------------------*/
-
- if ((employee_shnd == GS_INVALID_SHND) || /* */
- (manager_shnd == GS_INVALID_SHND))
- { /* invalid symbol handles */
- return GS_NO;
- }
-
- /*------------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*------------------------------------------------------------------*/
- /* A new employee cannot report to a manager whose number of */
- /* employees reporting to him is already maximal. */
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, manager_shnd, (PVOID)&manager, sizeof(manager
- ));
- if (manager.employee_num >= EMPLOYEE_MAX)
- { /* too many employees */
- return GS_NO;
- }
-
- /*------------------------------------------------------------------*/
- /* Store the information about the new employee in the manager data.*/
- /*------------------------------------------------------------------*/
-
- manager.employee_shnd[manager.employee_num] = employee_shnd;
- manager.employee_num++;
- GsPutSymObjectData(dhnd, manager_shnd, (PVOID)&manager, sizeof(manager
- ));
-
- /*------------------------------------------------------------------*/
- /* Create a link from the manager to the new employee. */
- /*------------------------------------------------------------------*/
-
- GsAddSym(dhnd, &link_shnd, LINK_PERSONS, LINK_FORM);
- GsPutSymTerminal(dhnd, link_shnd, GS_SOURCE, manager_shnd);
- GsPutSymTerminal(dhnd, link_shnd, GS_TARGET, employee_shnd);
-
- /*------------------------------------------------------------------*/
- /* Store the information about the manager in the employee data. */
- /*------------------------------------------------------------------*/
-
- employee.manager_shnd = manager_shnd;
- employee.pre_manager_shnd = manager_shnd;
- GsPutSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvEndMove */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_END_MOVE *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* POINTL mouse_pos (I): Position of the mouse pointer */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_REJECT The attempt to end the action is rejected and the */
- /* graphics editor retries the action processing. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_END_MOVE. */
- /* - The employee-manager relationship for the employees being */
- /* moved is determined. */
- /**********************************************************************/
-
- SHORT GSENTRY EvEndMove(DHND dhnd,SHORT ev_id,EVS_END_MOVE *pEvs)
- {
- SHND employee_shnd; /* handle of employee */
- EMPLOYEE employee; /* employee object data */
- SHORT rc; /* return code */
-
- /*------------------------------------------------------------------*/
- /* If all visible symbols representing employees have been moved, */
- /* the employee-manager relationship for all employees will not be */
- /* changed. */
- /*------------------------------------------------------------------*/
-
- if (AllVisibleEmployeesMoved(dhnd) == GS_YES)
- {
- return GS_RESTORE;
- }
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols representing employees being moved. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*----------------------------------------------------------------*/
- /* If the employee does not report to a manager, attach him to a */
- /* manager. */
- /*----------------------------------------------------------------*/
-
- if (employee.manager_shnd == GS_INVALID_SHND)
- {
- rc = AttachMoveEmployeeToManager(dhnd, employee_shnd);
- switch (rc)
- {
- case GS_YES :
- break;
- case GS_REJECT :
- DeleteAllNewLinks(dhnd);
- MSG_EMPLOYEE_NOT_ATTACHED(STR_PLACE_N_MOVED_DEP_MANAGER);
- GsEndSymCollection(dhnd);
- return (rc);
- default :
- GsEndSymCollection(dhnd);
- return GS_RESTORE;
- }
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* AllVisibleEmployeesMoved */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks whether all visible employees are moved. */
- /**********************************************************************/
-
- SHORT AllVisibleEmployeesMoved(DHND dhnd)
- {
- SHND employee_shnd; /* handle of employee */
- SHORT af; /* state of the action flag */
- SHORT shown; /* visibility of a symbol */
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols representing employees. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_ANY_SYM, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* See whether the symbol is visible. */
- /*----------------------------------------------------------------*/
-
- GsGetSymVisibility(dhnd, employee_shnd, &shown);
- if (shown == GS_ON)
- {
-
- /*--------------------------------------------------------------*/
- /* See whether the symbol has its action flag reset and is */
- /* therefore not moved. */
- /*--------------------------------------------------------------*/
-
- GsGetSymAf(dhnd, employee_shnd, &af);
- if (af == GS_OFF)
- {
- GsEndSymCollection(dhnd);
- return GS_NO;
- }
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* DeleteAllNewLinks */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function deletes all links connecting employees being moved */
- /* with their new manager. */
- /**********************************************************************/
-
- SHORT DeleteAllNewLinks(DHND dhnd)
- {
- SHND employee_shnd; /* handle of employee */
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols representing employees that have their */
- /* action flag set. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* See whether every symbol representing a manager to which the */
- /* employee is reporting has its action flag reset. */
- /*----------------------------------------------------------------*/
-
- if (ManagerAfOff(dhnd, employee_shnd) == GS_YES)
- { /* all action flags are reset */
-
- /*--------------------------------------------------------------*/
- /* Remove the employee from its manager. */
- /*--------------------------------------------------------------*/
-
- RemoveEmployee(dhnd, employee_shnd);
-
- /*--------------------------------------------------------------*/
- /* Delete the link between the employee and its manager. */
- /*--------------------------------------------------------------*/
-
- DeleteLink(dhnd, employee_shnd);
-
- /*--------------------------------------------------------------*/
- /* Remove the manager from the employee. */
- /*--------------------------------------------------------------*/
-
- RemoveManager(dhnd, employee_shnd);
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* ShowMsgAfterMovingEmployees */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function displays a message box that informs the end user */
- /* after having moved employees that could not be attached to a */
- /* manager. */
- /**********************************************************************/
-
- static VOID ShowMsgAfterMovingEmployees(DHND dhnd)
- {
- SHND employee_shnd; /* handle of employee */
- EMPLOYEE employee; /* employee object data */
- SHORT moved_employee_num; /* number of moved employees */
- SHORT moved_dep_manager_num;/* number of moved department
- managers */
-
- /*------------------------------------------------------------------*/
- /* Loop over all moved symbols representing employees. */
- /*------------------------------------------------------------------*/
-
- moved_employee_num = 0;
- moved_dep_manager_num = 0;
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
- moved_employee_num++;
-
- /*----------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*----------------------------------------------------------------*/
- /* See whether the employee is a department manager. */
- /*----------------------------------------------------------------*/
-
- if (employee.manager_shnd == GS_INVALID_SHND)
- {
- if (employee.employee_num)
- {
- moved_dep_manager_num++;
- }
- if (moved_dep_manager_num > 2)
- {
- GsEndSymCollection(dhnd);
- break;
- }
- }
- }
-
- /*------------------------------------------------------------------*/
- /* Display the appropriate message. */
- /*------------------------------------------------------------------*/
-
- if (moved_employee_num == 1)
- {
- MSG_EMPLOYEE_NOT_ATTACHED(STR_PLACE_MOVED_EMPLOYEE);
- }
- else
- {
- if (moved_dep_manager_num == 1)
- {
- MSG_EMPLOYEE_NOT_ATTACHED(STR_PLACE_1_MOVED_DEP_MANAGER);
- }
- else
- {
- MSG_EMPLOYEE_NOT_ATTACHED(STR_PLACE_N_MOVED_DEP_MANAGER);
- }
- }
- }
-
- /**********************************************************************/
- /* EvInit */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_INIT *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* VOID *pInit_data (I): Pointer passed from the customizing*/
- /* code to the parameter pInit_data of*/
- /* the GIK/2 function GsInitWin */
- /* HAB hab (I): Handle to anchor block */
- /* HWND hwnd_client (I): Handle to client window */
- /* HWND hwnd_frame (I): Handle to frame window */
- /* */
- /* Returns: */
- /* GS_NO The window is closed. */
- /* GS_YES The initialization of the GIK/2 window continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_INIT. */
- /**********************************************************************/
-
- SHORT GSENTRY EvInit(DHND dhnd,SHORT ev_id,EVS_INIT *pEvs)
- {
- ULONG cst; /* diagram constraints */
-
- /*------------------------------------------------------------------*/
- /* Store the handle of the symbol representing the general manager. */
- /* As there is no employee in the company, the value being stored is*/
- /* GS_INVALID_SHND. */
- /*------------------------------------------------------------------*/
-
- GsPutDiagLong(dhnd, (LONG)GS_INVALID_SHND);
-
- /*------------------------------------------------------------------*/
- /* The direct manipulation operation has to be a Move only. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagConstraint(dhnd, &cst);
- cst &= ~(GS_CST_DIAG_DRAG_COPY|GS_CST_DIAG_DRAG_LINK);
- GsPutDiagConstraint(dhnd, cst);
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvMenu */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_MENU *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHORT win_id (I): Identification of the window */
- /* It is one of the following: */
- /* GS_WIN_MAIN */
- /* GS_WIN_OV */
- /* USHORT menu_id (I): Identifier of the menu bar choice */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_MENU. */
- /* - Enables or disables choices of the 'Department' pull-down. */
- /* - Enables or disables pull-down choices for adding an employee. */
- /**********************************************************************/
-
- SHORT GSENTRY EvMenu(DHND dhnd,SHORT ev_id,EVS_MENU *pEvs)
- {
- LONG long_value; /* long value of the diagram */
- SHND gen_manager_shnd; /* handle of general manager */
- SHND shnd; /* symbol handle */
- SHORT shown; /* visibility of a symbol */
- SHORT state; /* state of the menu item */
- SHORT rc; /* return code */
- SHORT action_num; /* number of pending actions */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the general */
- /* manager. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagLong(dhnd, &long_value);
- gen_manager_shnd = LOUSHORT(long_value);
-
- /*------------------------------------------------------------------*/
- /* If the symbol representing the general manager is visible, the */
- /* 'Company' menu item is disabled. Otherwise it is enabled. */
- /*------------------------------------------------------------------*/
-
- if (gen_manager_shnd == GS_INVALID_SHND)
- { /* no general manager exists */
- state = GS_OFF;
- }
- else
- {
- GsGetSymVisibility(dhnd, gen_manager_shnd, &shown);
- if (shown == GS_ON)
- { /* the symbol is visible */
- state = GS_OFF;
- }
- else
- { /* the symbol is invisible */
- state = GS_ON;
- }
- }
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_COMPANY, state);
-
- /*------------------------------------------------------------------*/
- /* If at least one selected symbol is selected, the 'Development' */
- /* menu item is to enable. Otherwise it is to disable. */
- /*------------------------------------------------------------------*/
-
- state = GS_OFF;
- GsCollectSym(dhnd, GS_NODE, GS_SYM_SELECTED, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* See whether the symbol is visible. */
- /*----------------------------------------------------------------*/
-
- GsGetSymVisibility(dhnd, shnd, &shown);
- if (shown == GS_ON)
- {
- state = GS_ON;
- GsEndSymCollection(dhnd);
- break;
- }
- }
-
- /*------------------------------------------------------------------*/
- /* If at least one department manager is not selected, the 'Branch' */
- /* menu item is to enable. Otherwise it is to disable. */
- /*------------------------------------------------------------------*/
-
- if (state == GS_ON)
- {
- if (NotSelectedDepManager(dhnd, gen_manager_shnd) == GS_NO)
- state = GS_OFF;
- }
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_BRANCH, state);
-
- /*------------------------------------------------------------------*/
- /* If actions are pending, some action cannot be processed. */
- /*------------------------------------------------------------------*/
-
- GsGetAction(dhnd, NULL, &action_num);
- if (action_num > 1)
- {
- state = GS_OFF;
- }
- else
- {
- state = GS_ON;
- }
- if (state == GS_OFF)
- {
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_CLEAR, state);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_SELECT_ALL, state);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_DESELECT, state);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_COLOR, state);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_SET_FONT, state);
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, AID_RESET_FONT, state);
- }
-
- /*------------------------------------------------------------------*/
- /* If actions are pending and if no symbol representing an employee */
- /* in the company is visible, some action cannot be processed. */
- /*------------------------------------------------------------------*/
-
- if (state == GS_ON)
- {
- rc = VisibleEmployee(dhnd);
- if (rc == GS_NO)
- {
- state = GS_OFF;
- }
- }
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, MID_NODE, state);
- if (state == GS_ON)
- {
- if (rc == GS_REJECT)
- {
- state = GS_OFF;
- }
- }
- GsPutMenuItemEnabled(dhnd, GS_WIN_MAIN, MID_LAY, state);
- return GS_YES;
- }
-
- /**********************************************************************/
- /* NotSelectedDepManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function retrieves the handle of a department manager */
- /* of which the symbol that is representing him is not selected. */
- /**********************************************************************/
-
- SHORT NotSelectedDepManager(DHND dhnd,SHND employee_shnd)
- {
- SHORT shown; /* visibility of a symbol */
- SHORT selection; /* selection state of a symbol */
- EMPLOYEE employee; /* employee object data */
- SHORT cnt; /* symbol count */
-
- /*------------------------------------------------------------------*/
- /* See whether the symbol is visible. */
- /*------------------------------------------------------------------*/
-
- GsGetSymVisibility(dhnd, employee_shnd, &shown);
- if (shown == GS_ON)
- { /* it is visible */
-
- /*----------------------------------------------------------------*/
- /* See whether the symbol is selected. */
- /*----------------------------------------------------------------*/
-
- GsGetSymSelection(dhnd, employee_shnd, &selection);
- if (selection == GS_OFF)
- { /* it is not selected */
- return GS_YES;
- }
- else
- { /* it is selected */
- return GS_NO;
- }
- }
- else
- { /* it is invisible */
-
- /*----------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*----------------------------------------------------------------*/
- /* Loop over all employees reporting to the current employee. */
- /*----------------------------------------------------------------*/
-
- for (cnt = 0; cnt < employee.employee_num; cnt++)
- {
- if (NotSelectedDepManager(dhnd, employee.employee_shnd[cnt]) ==
- GS_YES)
- return GS_YES;
- }
- }
- return GS_NO;
- }
-
- /**********************************************************************/
- /* VisibleEmployee */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_REJECT */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks whether at leastone symbol representing an */
- /* employee is visible. */
- /**********************************************************************/
-
- SHORT VisibleEmployee(DHND dhnd)
- {
- SHND gen_manager_shnd; /* handle of general manager */
- SHND employee_shnd; /* handle of employee */
- SHORT shown; /* visibility of a symbol */
- LONG long_value; /* long value of the diagram */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the general */
- /* manager. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagLong(dhnd, &long_value);
- gen_manager_shnd = LOUSHORT(long_value);
-
- /*------------------------------------------------------------------*/
- /* If no general manager exists, symbols cannot be visible. */
- /*------------------------------------------------------------------*/
-
- if (gen_manager_shnd == GS_INVALID_SHND)
- {
- return GS_REJECT;
- }
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols representing employees. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_ANY_SYM, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* See whether the symbol is visible. */
- /*----------------------------------------------------------------*/
-
- GsGetSymVisibility(dhnd, employee_shnd, &shown);
- if (shown == GS_ON)
- {
- GsEndSymCollection(dhnd);
- return GS_YES;
- }
- }
- return GS_NO;
- }
-
- /**********************************************************************/
- /* EvNew */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* VOID *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_NEW. */
- /**********************************************************************/
-
- SHORT GSENTRY EvNew(DHND dhnd,SHORT ev_id,VOID *pEvs)
- {
-
- /*------------------------------------------------------------------*/
- /* Store the handle of the symbol representing the general manager. */
- /* As there is no employee in the company, the value being stored is*/
- /* GS_INVALID_SHND. */
- /*------------------------------------------------------------------*/
-
- GsPutDiagLong(dhnd, (LONG)GS_INVALID_SHND);
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvStartAdd */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_START_ADD *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHND shnd (I): Handle of the symbol */
- /* SHORT sym_class (I): Class of the symbol. It is one of */
- /* the following: */
- /* GS_NODE */
- /* GS_LINK */
- /* SHORT sym_type (I): Type of the symbol */
- /* SHORT sym_form (I): Form of the symbol */
- /* SHORT palette (I): Palette indicator */
- /* It specifies whether a symbol is */
- /* being added from the Symbol */
- /* Palette. It is one of the */
- /* following: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Returns: */
- /* GS_END The action is ended in the same way the end user */
- /* would end the action. */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_START_ADD. */
- /* - Checks whether symbols are visible so that the new symbol can */
- /* be attached to one of them. */
- /**********************************************************************/
-
- SHORT GSENTRY EvStartAdd(DHND dhnd,SHORT ev_id,EVS_START_ADD *pEvs)
- {
- SHORT action_num; /* number of pending actions */
-
- /*------------------------------------------------------------------*/
- /* If actions are pending, adding of symbols is not allowed. */
- /*------------------------------------------------------------------*/
-
- GsGetAction(dhnd, NULL, &action_num);
- if (action_num > 1)
- {
- return GS_RESTORE;
- }
-
- /*------------------------------------------------------------------*/
- /* If no symbol representing an employee in the company is visible, */
- /* adding of symbols is not allowed. */
- /*------------------------------------------------------------------*/
-
- if (VisibleEmployee(dhnd) == GS_NO)
- {
- return GS_RESTORE;
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvStartMove */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_START_MOVE *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHND shnd (I): Handle of the symbol */
- /* SHORT bp_ref (I): Reference number of the new bend */
- /* This member is GS_INVALID_BP if the*/
- /* end user clicks on a node symbol */
- /* instead of a bend point. */
- /* POINTL mouse_pos (I): Position of the mouse pointer */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_START_MOVE. */
- /* - Node symbols that are to maove and their children are marked */
- /* for movement. */
- /**********************************************************************/
-
- SHORT GSENTRY EvStartMove(DHND dhnd,SHORT ev_id,EVS_START_MOVE *pEvs)
- {
- SHND employee_shnd; /* handle of employee */
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols representing employees that have their */
- /* action flag set. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* Mark symbols for movement. */
- /*----------------------------------------------------------------*/
-
- PutAllSubtreeSymAf(dhnd, employee_shnd, FALSE);
-
- /*----------------------------------------------------------------*/
- /* See whether every symbol representing a manager to which the */
- /* employee is reporting has its action flag reset. */
- /*----------------------------------------------------------------*/
-
- if (ManagerAfOff(dhnd, employee_shnd) == GS_YES)
- { /* all action flags are reset */
-
- /*--------------------------------------------------------------*/
- /* Remove the employee from its manager. */
- /*--------------------------------------------------------------*/
-
- RemoveEmployee(dhnd, employee_shnd);
-
- /*--------------------------------------------------------------*/
- /* Delete the link between the employee and its manager. */
- /*--------------------------------------------------------------*/
-
- DeleteLink(dhnd, employee_shnd);
-
- /*--------------------------------------------------------------*/
- /* Remove the manager from the employee. */
- /*--------------------------------------------------------------*/
-
- RemoveManager(dhnd, employee_shnd);
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* ManagerAfOff */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks whether the symbol representing the manager */
- /* of a given employee has its action flag reset. */
- /**********************************************************************/
-
- SHORT ManagerAfOff(DHND dhnd,SHND employee_shnd)
- {
- EMPLOYEE employee; /* employee object data */
- SHORT af; /* state of the action flag */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the employee data. */
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*------------------------------------------------------------------*/
- /* See whether the employee is reporting to a manager. */
- /*------------------------------------------------------------------*/
-
- if (employee.manager_shnd != GS_INVALID_SHND)
- { /* the employee reports to a
- manager */
-
- /*----------------------------------------------------------------*/
- /* See whether the symbol representing the manager to which the */
- /* employee is reporting has its action flag set. */
- /*----------------------------------------------------------------*/
-
- GsGetSymAf(dhnd, employee.manager_shnd, &af);
- if (af == GS_ON)
- {
- return GS_NO;
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* DeleteLink */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function removes the link between an employee and its */
- /* manager. */
- /**********************************************************************/
-
- static VOID DeleteLink(DHND dhnd,SHND employee_shnd)
- {
- SHND link_shnd; /* handle of link symbol */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the link between employee and its manager.*/
- /*------------------------------------------------------------------*/
-
- GsGetFirstAttachedSym(dhnd, GS_TARGET_ATTACHED_LINK, employee_shnd,
- &link_shnd, NULL);
-
- /*------------------------------------------------------------------*/
- /* Delete the link. */
- /*------------------------------------------------------------------*/
-
- if (link_shnd != GS_INVALID_SHND)
- {
- GsDeleteSym(dhnd, link_shnd);
- }
- }
-
- /**********************************************************************/
- /* RemoveManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function removes the manager from an employee. */
- /**********************************************************************/
-
- static VOID RemoveManager(DHND dhnd,SHND employee_shnd)
- {
- EMPLOYEE employee; /* employee object data */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*------------------------------------------------------------------*/
- /* See whether the employee is reporting to a manager. */
- /*------------------------------------------------------------------*/
-
- if (employee.manager_shnd != GS_INVALID_SHND)
- { /* the employee reports to a
- manager */
-
- /*----------------------------------------------------------------*/
- /* Store the information that the manager is removed. */
- /*----------------------------------------------------------------*/
-
- employee.manager_shnd = GS_INVALID_SHND;
-
- /*----------------------------------------------------------------*/
- /* Store the employee object data. */
- /*----------------------------------------------------------------*/
-
- GsPutSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
- }
- }
-
- /**********************************************************************/
- /* EvDragOver */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_DRAG_OVER *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* DRAGINFO *pDrag_info (I): Pointer to data type describing */
- /* the direct manipulation operation */
- /* POINTL mouse_pos (I): Position of the mouse pointer */
- /* DRAGIMAGE *pDrag_image (I): Pointer to an array of DRAGIMAGE */
- /* data types */
- /* The array describes the image to */
- /* be displayed for the dragged items.*/
- /* It is NULL if no GIK/2 objects are */
- /* being dragged. */
- /* SHORT num (I/O): Number of items dragged */
- /* HPOINTER hptr (I/O): Handle of the mouse pointer */
- /* MRESULT mresult (I/O): Return code for the message */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_REJECT The attempt to end the action is rejected and the */
- /* graphics editor retries the action processing. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_DRAG_OVER. */
- /* - Checks whether all items being dragged are symbols. */
- /* - Checks whether symbols exists to which the dragged symbols */
- /* are allowed to be attached. */
- /**********************************************************************/
-
- SHORT GSENTRY EvDragOver(DHND dhnd,SHORT ev_id,EVS_DRAG_OVER *pEvs)
- {
- SHORT action_num; /* number of pending actions */
- SHORT action_max_num; /* maximum number of pending
- actions that is allowed */
- SHND employee_shnd; /* handle of employee */
- RECTL area; /* hit area */
- DRAGITEM *pDrag_item; /* pointer to data of a dragged
- object */
- SHORT rc; /* return code */
- HWND hwnd; /* window handle */
- BOOL is_source; /* indicates whether the window
- being dragged over is the
- source window of the direct
- manipulation operation */
-
- /*------------------------------------------------------------------*/
- /* See whether the window being dragged over is the source window of*/
- /* the of the direct manipulation operation. */
- /*------------------------------------------------------------------*/
-
- GsGetHwnd(dhnd, GS_WIN_MAIN, 0, FID_CLIENT, &hwnd);
- is_source = (hwnd == pEvs->pDrag_info->hwndSource);
-
- /*------------------------------------------------------------------*/
- /* If actions are pending, symbols cannot be dropped. */
- /*------------------------------------------------------------------*/
-
- GsGetAction(dhnd, NULL, &action_num);
- if (is_source)
- {
- action_max_num = 2;
- }
- else
- {
- action_max_num = 1;
- }
- if (action_num > action_max_num)
- {
- pEvs->mresult = MRFROMSHORT(DOR_NEVERDROP);
- return GS_YES;
- }
-
- /*------------------------------------------------------------------*/
- /* If items being dragged are not symbols, a drop is not allowed. */
- /*------------------------------------------------------------------*/
-
- if (SymDragged(dhnd, pEvs->pDrag_info) == GS_NO)
- {
- pEvs->mresult = MRFROMSHORT(DOR_NEVERDROP);
- return GS_YES;
- }
-
- /*------------------------------------------------------------------*/
- /* If all visible symbols representing employees are being dragged, */
- /* adding of symbols is not allowed. */
- /*------------------------------------------------------------------*/
-
- rc = AllVisibleEmployeesDragged(dhnd, pEvs->pDrag_info);
- switch (rc)
- {
- case GS_YES : /* all visible symbol are being
- dragged */
- pEvs->mresult = MRFROMSHORT(DOR_NEVERDROP);
- break;
- case GS_REJECT : /* no symbol exists */
- if (is_source)
- {
- pEvs->mresult = MRFROMSHORT(DOR_NEVERDROP);
- }
- break;
- default : /* some visible symbols are not
- being dragged */
-
- /*--------------------------------------------------------------*/
- /* Determine the area to be used for a hit detection. */
- /*--------------------------------------------------------------*/
-
- area.xLeft = pEvs->mouse_pos.x-GS_HALF_HIT_WIDTH;
- area.yBottom = pEvs->mouse_pos.y-GS_HALF_HIT_HEIGHT;
- area.xRight = pEvs->mouse_pos.x+GS_HALF_HIT_WIDTH;
- area.yTop = pEvs->mouse_pos.y+GS_HALF_HIT_HEIGHT;
-
- /*--------------------------------------------------------------*/
- /* See whether the mouse pointer is on a symbol representing an */
- /* employee. */
- /*--------------------------------------------------------------*/
-
- if (GsGetFirstHitSym(dhnd, GS_NODE, GS_UPPER_FIRST, &area,
- &employee_shnd, NULL, NULL, NULL) != GS_OK)
- { /* the pointer is not on a
- symbol */
- pEvs->mresult = MRFROMSHORT(DOR_NODROP);
- }
- else
- { /* the pointer is on a symbol */
-
- /*------------------------------------------------------------*/
- /* See whether the mouse pointer is on a symbol representing */
- /* an employee currently being dragged. */
- /*------------------------------------------------------------*/
-
- GsGetDragItem(dhnd, employee_shnd, &pDrag_item);
- if (pDrag_item)
- { /* the symbol the mouse pointer
- is on is being dragged */
- pEvs->mresult = MRFROMSHORT(DOR_NODROP);
- }
- }
- break;
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* SymDragged */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* DRAGINFO *pDrag_info (I): Drag info */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks whether all items being dragged are symbols. */
- /**********************************************************************/
-
- SHORT SymDragged(DHND dhnd,DRAGINFO *pDrag_info)
- {
- SHORT num; /* number items being dragged */
- SHORT sym_id; /* symbol index */
- DRAGITEM *pDrag_item; /* pointer to data of a dragged
- object */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the number of items being dragged. */
- /*------------------------------------------------------------------*/
-
- num = DrgQueryDragitemCount(pDrag_info);
-
- /*------------------------------------------------------------------*/
- /* Loop over all items being dragged. */
- /*------------------------------------------------------------------*/
-
- for (sym_id = 0; sym_id < num; sym_id++)
- {
-
- /*----------------------------------------------------------------*/
- /* Get the item info. */
- /*----------------------------------------------------------------*/
-
- pDrag_item = DrgQueryDragitemPtr(pDrag_info, (ULONG)sym_id);
-
- /*----------------------------------------------------------------*/
- /* See whether the item is a symbol. */
- /*----------------------------------------------------------------*/
-
- if (!DrgVerifyType(pDrag_item, GS_DRT_SYM))
- { /* it is not a symbol */
- return GS_NO;
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* AllVisibleEmployeesDragged */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* DRAGINFO *pDrag_info (I): Drag info */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_REJECT */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks whether all visible employees are dragged. */
- /**********************************************************************/
-
- SHORT AllVisibleEmployeesDragged(DHND dhnd,DRAGINFO *pDrag_info)
- {
- SHND gen_manager_shnd; /* handle of general manager */
- SHND employee_shnd; /* handle of employee */
- LONG long_value; /* long value of the diagram */
- SHORT shown; /* visibility of a symbol */
- DRAGITEM *pDrag_item; /* pointer to data of a dragged
- object */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the general */
- /* manager. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagLong(dhnd, &long_value);
- gen_manager_shnd = LOUSHORT(long_value);
-
- /*------------------------------------------------------------------*/
- /* See whether a general manager exists. */
- /*------------------------------------------------------------------*/
-
- if (gen_manager_shnd == GS_INVALID_SHND)
- {
- return GS_REJECT;
- }
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols representing employees. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_ANY_SYM, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* See whether the symbol is visible. */
- /*----------------------------------------------------------------*/
-
- GsGetSymVisibility(dhnd, employee_shnd, &shown);
- if (shown == GS_ON)
- { /* the symbol is visible */
-
- /*--------------------------------------------------------------*/
- /* See whether the symbol represents an employee currently being*/
- /* dragged. */
- /*--------------------------------------------------------------*/
-
- GsGetDragItem(dhnd, employee_shnd, &pDrag_item);
- if (!pDrag_item)
- { /* the symbol is not being
- dragged */
- GsEndSymCollection(dhnd);
- return GS_NO;
- }
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvDrop */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_DROP *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* DRAGINFO *pDrag_info (I): Pointer to data type describing */
- /* the direct manipulation operation */
- /* POINTL mouse_pos (I): Position of the mouse pointer */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_DROP. */
- /* - The employee-manager relationship for the employees being */
- /* dropped is determined. */
- /**********************************************************************/
-
- SHORT GSENTRY EvDrop(DHND dhnd,SHORT ev_id,EVS_DROP *pEvs)
- {
- SHND employee_shnd; /* handle of employee */
- SHND shnd; /* symbol handle */
- SHORT rc; /* return code */
- HWND hwnd; /* window handle */
-
- /*------------------------------------------------------------------*/
- /* Update the object data of all dropped symbols representing */
- /* employees. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
- UpdateEmployeeData(dhnd, pEvs->pDrag_info, employee_shnd);
- }
-
- /*------------------------------------------------------------------*/
- /* If the company has no general manager and only one employee has */
- /* been dropped that does not report to a manager, it becomes */
- /* general manager. */
- /*------------------------------------------------------------------*/
-
- rc = DropEmployeeForGenManager(dhnd);
- switch (rc)
- {
- case GS_NO :
- return GS_RESTORE;
-
- case GS_REJECT :
-
- /*--------------------------------------------------------------*/
- /* Adds the dropped employee the mouse pointer is on to the */
- /* manager the mouse pointer is on. */
- /*--------------------------------------------------------------*/
-
- if (AttachDrop1EmployeeToManager(dhnd, pEvs->mouse_pos) != GS_YES)
- {
- return GS_RESTORE;
- }
-
- /*--------------------------------------------------------------*/
- /* Adds all dropped employees that do not report to a manager to*/
- /* a manager. */
- /*--------------------------------------------------------------*/
-
- if (AttachDropNEmployeeToManager(dhnd) != GS_YES)
- {
- return GS_RESTORE;
- }
- break;
- }
-
- /*------------------------------------------------------------------*/
- /* Do not allow performing a layout algorithm if the target window */
- /* of the direct manipulation operation is the same as the source */
- /* window. */
- /*------------------------------------------------------------------*/
-
- GsGetHwnd(dhnd, GS_WIN_MAIN, 0, FID_CLIENT, &hwnd);
- if (hwnd == pEvs->pDrag_info->hwndSource)
- {
-
- /*----------------------------------------------------------------*/
- /* The function marks all links between employees and their */
- /* manager. */
- /*----------------------------------------------------------------*/
-
- PutAllLinkToPreManagerAf(dhnd);
-
- /*----------------------------------------------------------------*/
- /* Set the visibility state of all new symbols. */
- /*----------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_ANY_CLASS, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) == GS_OK)
- {
- GsPutSymVisibility(dhnd, shnd, GS_OFF);
- GsPutSymFlag(dhnd, shnd, SF_INVISIBLE, SF_INVISIBLE);
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* UpdateEmployeeData */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* DRAGINFO *pDrag_info (I): Drag info */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function updates the object data of an employee. */
- /**********************************************************************/
-
- static VOID UpdateEmployeeData(DHND dhnd,DRAGINFO *pDrag_info,SHND
- employee_shnd)
- {
- EMPLOYEE employee; /* employee object data */
- SHORT cnt; /* symbol count */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the employee data. */
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*------------------------------------------------------------------*/
- /* Update the handle of the symbol representing the manager. */
- /*------------------------------------------------------------------*/
-
- if (employee.manager_shnd != GS_INVALID_SHND)
- { /* the employee reports to a
- manager */
- GetTargetNode(dhnd, pDrag_info, employee.manager_shnd,
- &employee.manager_shnd);
- }
- employee.pre_manager_shnd = employee.manager_shnd;
-
- /*------------------------------------------------------------------*/
- /* Update the handles of all symbols representing employees */
- /* reporting to the current employee. */
- /*------------------------------------------------------------------*/
-
- for (cnt = 0; cnt < employee.employee_num; cnt++)
- {
- GetTargetNode(dhnd, pDrag_info, employee.employee_shnd[cnt],
- &employee.employee_shnd[cnt]);
- }
-
- /*------------------------------------------------------------------*/
- /* Store the employee object data. */
- /*------------------------------------------------------------------*/
-
- GsPutSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
- }
-
- /**********************************************************************/
- /* GetTargetNode */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* DRAGINFO *pDrag_info (I): Drag info */
- /* SHND source_shnd (I): source symbol handle */
- /* SHND *pTarget_shnd (I): target symbol handle */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function retrieves the symbol handle in the target window */
- /* of a node symbol having been dropped. */
- /**********************************************************************/
-
- static VOID GetTargetNode(DHND dhnd,DRAGINFO *pDrag_info,SHND
- source_shnd,SHND *pTarget_shnd)
- {
- SHORT num; /* number items being dragged */
- SHORT sym_id; /* symbol index */
- DRAGITEM *pDrag_sym; /* pointer to data of the
- dropped symbol */
- DRAGITEM *pDrag_item; /* pointer to data of a dragged
- object */
- SHND shnd; /* symbol handle */
-
- /*------------------------------------------------------------------*/
- /* Initial value for the handle. */
- /*------------------------------------------------------------------*/
-
- *pTarget_shnd = GS_INVALID_SHND;
-
- /*------------------------------------------------------------------*/
- /* Retrieve the number of items having been dragged. */
- /*------------------------------------------------------------------*/
-
- num = DrgQueryDragitemCount(pDrag_info);
-
- /*------------------------------------------------------------------*/
- /* Loop over all items having been dragged. */
- /*------------------------------------------------------------------*/
-
- pDrag_sym = NULL;
- for (sym_id = 0; sym_id < num; sym_id++)
- {
-
- /*----------------------------------------------------------------*/
- /* Get the item info. */
- /*----------------------------------------------------------------*/
-
- pDrag_item = DrgQueryDragitemPtr(pDrag_info, (ULONG)sym_id);
-
- /*----------------------------------------------------------------*/
- /* See whether the item is a symbol. */
- /*----------------------------------------------------------------*/
-
- if (DrgVerifyType(pDrag_item, GS_DRT_SYM))
- { /* it is a symbol */
-
- /*--------------------------------------------------------------*/
- /* Check the symbol handle. */
- /*--------------------------------------------------------------*/
-
- if ((SHND)(LOUSHORT(pDrag_item->ulItemID)) == source_shnd)
- {
- pDrag_sym = pDrag_item;
- break;
- }
- }
- }
-
- /*------------------------------------------------------------------*/
- /* See whether the symbol has been dragged. */
- /*------------------------------------------------------------------*/
-
- if (pDrag_sym)
- { /* the symbol has been dragged */
-
- /*----------------------------------------------------------------*/
- /* Loop over all dropped node symbols. */
- /*----------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) == GS_OK)
- {
-
- /*--------------------------------------------------------------*/
- /* Compare the pointers to the data used for dragged items. */
- /*--------------------------------------------------------------*/
-
- GsGetDragItem(dhnd, shnd, &pDrag_item);
- if (pDrag_item == pDrag_sym)
- { /* symbol is found */
- *pTarget_shnd = shnd;
- GsEndSymCollection(dhnd);
- break;
- }
- }
- }
- }
-
- /**********************************************************************/
- /* DropEmployeeForGenManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* GS_NO */
- /* GS_REJECT */
- /* GS_YES */
- /* */
- /* Description: */
- /* The function checks whether the dropped employees are the first */
- /* having been added to the company. One of them becomes general */
- /* manager. */
- /**********************************************************************/
-
- SHORT DropEmployeeForGenManager(DHND dhnd)
- {
- SHND gen_manager_shnd; /* handle of general manager */
- SHND employee_shnd; /* handle of employee */
- EMPLOYEE employee; /* employee object data */
- LONG long_value; /* long value of the diagram */
- SHORT employee_num; /* number of employees not
- reporting to a manager */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the general */
- /* manager. */
- /*------------------------------------------------------------------*/
-
- GsGetDiagLong(dhnd, &long_value);
- gen_manager_shnd = LOUSHORT(long_value);
-
- /*------------------------------------------------------------------*/
- /* See whether a general manager exists. */
- /*------------------------------------------------------------------*/
-
- if (gen_manager_shnd != GS_INVALID_SHND)
- { /* a general manager exists */
- return GS_REJECT;
- }
- else
- { /* no general manager exists */
-
- /*----------------------------------------------------------------*/
- /* Loop over all dropped symbols representing employees. */
- /*----------------------------------------------------------------*/
-
- employee_num = 0;
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*--------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*--------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*--------------------------------------------------------------*/
- /* Retrieve the handle of the symbol representing the first */
- /* employee that does not report to a manager. */
- /*--------------------------------------------------------------*/
-
- if (employee.manager_shnd == GS_INVALID_SHND)
- {
- employee_num++;
- if (gen_manager_shnd == GS_INVALID_SHND)
- {
- gen_manager_shnd = employee_shnd;
- }
- }
- }
-
- /*----------------------------------------------------------------*/
- /* If there is only one employee that does not report to a */
- /* manager, it is stored as general manager. */
- /*----------------------------------------------------------------*/
-
- if (employee_num == 1)
- {
- GsPutDiagLong(dhnd, (LONG)gen_manager_shnd);
- return GS_YES;
- }
- }
- return GS_NO;
- }
-
- /**********************************************************************/
- /* AttachDrop1EmployeeToManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* POINTL mouse_pos (I): Position of the mouse pointer */
- /* */
- /* Returns: */
- /* GS_NO the attachment is not done */
- /* GS_YES the attachment is done */
- /* */
- /* Description: */
- /* The function adds the dropped employee the mouse pointer is on */
- /* to a manager the mouse pointer is on. */
- /**********************************************************************/
-
- SHORT AttachDrop1EmployeeToManager(DHND dhnd,POINTL mouse_pos)
- {
- SHND employee_shnd; /* handle of employee */
- SHND manager_shnd; /* handle of manager */
- SHND shnd; /* symbol handle */
- RECTL area; /* hit area */
- SHORT af; /* state of the action flag */
-
- /*------------------------------------------------------------------*/
- /* Determine the area to be used for a hit detection. */
- /*------------------------------------------------------------------*/
-
- area.xLeft = mouse_pos.x-GS_HALF_HIT_WIDTH;
- area.yBottom = mouse_pos.y-GS_HALF_HIT_HEIGHT;
- area.xRight = mouse_pos.x+GS_HALF_HIT_WIDTH;
- area.yTop = mouse_pos.y+GS_HALF_HIT_HEIGHT;
-
- /*------------------------------------------------------------------*/
- /* Retrieve the handles of the two symbols the mouse pointer is on. */
- /*------------------------------------------------------------------*/
-
- employee_shnd = GS_INVALID_SHND;
- manager_shnd = GS_INVALID_SHND;
- GsCollectHitSym(dhnd, GS_NODE, GS_UPPER_FIRST, &area);
- while (GsGetCollectedHitSym(dhnd, &shnd, NULL, NULL, NULL) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* See whether it is a symbol having been dropped. */
- /*----------------------------------------------------------------*/
-
- GsGetSymAf(dhnd, shnd, &af);
- if (af == GS_ON)
- { /* the symbol has been dropped */
- employee_shnd = shnd;
- }
- else
- { /* the symbol has not been
- dropped */
- manager_shnd = shnd;
- }
-
- /*----------------------------------------------------------------*/
- /* See whether the handles of the two symbols the mouse pointer is*/
- /* on have been retrieved. */
- /*----------------------------------------------------------------*/
-
- if ((employee_shnd != GS_INVALID_SHND) && /* */
- (manager_shnd != GS_INVALID_SHND))
- {
- GsEndHitSymCollection(dhnd);
- break;
- }
- }
-
- /*------------------------------------------------------------------*/
- /* Define the employee-manager relationship. */
- /*------------------------------------------------------------------*/
-
- return AttachEmployeeToManager(dhnd, employee_shnd, manager_shnd);
- }
-
- /**********************************************************************/
- /* AttachDropNEmployeeToManager */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* GS_NO the attachment is not done */
- /* GS_REJECT the attachment is not done */
- /* GS_YES the attachment is done */
- /* */
- /* Description: */
- /* The function adds all dropped employee that do not report to */
- /* a manager to a manager. */
- /**********************************************************************/
-
- SHORT AttachDropNEmployeeToManager(DHND dhnd)
- {
- SHND employee_shnd; /* handle of employee */
- EMPLOYEE employee; /* employee object data */
- SHORT rc; /* return code */
-
- /*------------------------------------------------------------------*/
- /* Loop over all dropped symbols representing employees. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*----------------------------------------------------------------*/
- /* See whether the employee reports to a manager. */
- /*----------------------------------------------------------------*/
-
- if (employee.manager_shnd == GS_INVALID_SHND)
- { /* it does not report to a
- manager */
- if ((rc = AttachMoveEmployeeToManager(dhnd, employee_shnd)) !=
- GS_YES)
- {
- GsEndSymCollection(dhnd);
- return (rc);
- }
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* EvEndDrag */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_END_DRAG *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* DRAGINFO *pDrag_info (I): Pointer to data type describing */
- /* the direct manipulation operation */
- /* HWND hwnd_target (I): Handle of the target window */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_END_DRAG. */
- /**********************************************************************/
-
- SHORT GSENTRY EvEndDrag(DHND dhnd,SHORT ev_id,EVS_END_DRAG *pEvs)
- {
- SHND shnd; /* symbol handle */
- ULONG sym_flags; /* symbol flags */
- HWND hwnd; /* window handle */
-
- /*------------------------------------------------------------------*/
- /* The function marks all links between employees and their previous*/
- /* manager. */
- /*------------------------------------------------------------------*/
-
- PutAllLinkToPreManagerAf(dhnd);
-
- /*------------------------------------------------------------------*/
- /* Set the visibility state of all new symbols if the target window */
- /* of the direct manipulation operation is the same as the source */
- /* window. */
- /*------------------------------------------------------------------*/
-
- GsGetHwnd(dhnd, GS_WIN_MAIN, 0, FID_CLIENT, &hwnd);
- if (hwnd == pEvs->hwnd_target)
- {
-
- /*----------------------------------------------------------------*/
- /* Loop over all symbols. */
- /*----------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_ANY_CLASS, GS_ANY_SYM, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &shnd) == GS_OK)
- {
-
- /*--------------------------------------------------------------*/
- /* See whether the symbol is new. */
- /*--------------------------------------------------------------*/
-
- GsGetSymFlag(dhnd, shnd, &sym_flags);
- if (sym_flags&SF_INVISIBLE)
- {
- GsPutSymVisibility(dhnd, shnd, GS_ON);
- GsPutSymFlag(dhnd, shnd, ~SF_INVISIBLE, SF_INVISIBLE);
- }
- }
- }
- return GS_YES;
- }
-
- /**********************************************************************/
- /* PutAllLinkToPreManagerAf */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function sets the action flag of all links between employees */
- /* and their previous manager. */
- /**********************************************************************/
-
- static VOID PutAllLinkToPreManagerAf(DHND dhnd)
- {
- SHND employee_shnd; /* handle of employee */
- EMPLOYEE employee; /* employee object data */
-
- /*------------------------------------------------------------------*/
- /* Loop over all symbols representing employees having been dragged.*/
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*----------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*----------------------------------------------------------------*/
- /* If the employee does not report to a manager, delete the link */
- /* between the employee and its previous manager. */
- /*----------------------------------------------------------------*/
-
- if (employee.manager_shnd == GS_INVALID_SHND)
- {
- PutLinkToPreManagerAf(dhnd, employee_shnd);
- }
- }
- }
-
- /**********************************************************************/
- /* PutLinkToPreManagerAf */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle */
- /* SHND employee_shnd (I): handle of employee */
- /* */
- /* Returns: */
- /* VOID */
- /* */
- /* Description: */
- /* The function sets the action flag of the link between an employee*/
- /* and its previous manager. */
- /**********************************************************************/
-
- static VOID PutLinkToPreManagerAf(DHND dhnd,SHND employee_shnd)
- {
- EMPLOYEE employee; /* employee object data */
- SHND link_shnd; /* handle of link symbol */
-
- /*------------------------------------------------------------------*/
- /* Retrieve the employee object data. */
- /*------------------------------------------------------------------*/
-
- GsGetSymObjectData(dhnd, employee_shnd, (PVOID)&employee, sizeof
- (employee));
-
- /*------------------------------------------------------------------*/
- /* See whether the employee is reporting to a manager. */
- /*------------------------------------------------------------------*/
-
- if (employee.pre_manager_shnd != GS_INVALID_SHND)
- { /* the employee reports to a
- manager */
-
- /*----------------------------------------------------------------*/
- /* Retrieve the handle of the link. */
- /*----------------------------------------------------------------*/
-
- GsGetFirstAttachedSym(dhnd, GS_TARGET_ATTACHED_LINK, employee_shnd,
- &link_shnd, NULL);
-
- /*----------------------------------------------------------------*/
- /* Mark the link. */
- /*----------------------------------------------------------------*/
-
- if (link_shnd != GS_INVALID_SHND)
- {
- GsPutSymAf(dhnd, link_shnd, GS_ON);
- }
- }
- }
-
- /**********************************************************************/
- /* EvStartDrag */
- /* */
- /* Parameters: */
- /* DHND dhnd (I): Diagram handle. */
- /* SHORT ev_id (I): Identifies the event. */
- /* EVS_START_DRAG *pEvs (I): Pointer to instance of event*/
- /* data type. */
- /* SHND shnd (I): Handle of the symbol */
- /* POINTL mouse_pos (I): Position of the mouse pointer */
- /* */
- /* Returns: */
- /* GS_NO Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_NO_1 Any changes made to symbols remain and the action */
- /* stops. */
- /* GS_RESTORE Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_RESTORE_1 Any changes made to symbols since the last undo */
- /* checkpoint are undone and the action stops. */
- /* GS_YES The default processing continues. */
- /* */
- /* Description: */
- /* The function handles the event EV_START_DRAG. */
- /* - Link symbol are not allowed to be dragged. */
- /**********************************************************************/
-
- SHORT GSENTRY EvStartDrag(DHND dhnd,SHORT ev_id,EVS_START_DRAG *pEvs)
- {
- SHORT sym_class; /* class of the symbol */
- SHND employee_shnd; /* handle of employee */
-
- /*------------------------------------------------------------------*/
- /* If the symbol the mouse pointer is on a link, drag and drop is */
- /* not started. */
- /*------------------------------------------------------------------*/
-
- GsGetSymClass(dhnd, pEvs->shnd, &sym_class);
- if (sym_class == GS_LINK)
- {
- return GS_RESTORE;
- }
-
- /*------------------------------------------------------------------*/
- /* Clear the undo stack. This is necessary to restore the current */
- /* situation if the drag operation will be stopped by the end user. */
- /*------------------------------------------------------------------*/
-
- GsResetUndo(dhnd);
-
- /*------------------------------------------------------------------*/
- /* Mark symbols for dragging. All selected symbols representing */
- /* employees have the action flag already set. */
- /*------------------------------------------------------------------*/
-
- GsCollectSym(dhnd, GS_NODE, GS_SYM_AF, GS_UPPER_FIRST);
- while (GsGetCollectedSym(dhnd, &employee_shnd) == GS_OK)
- {
-
- /*----------------------------------------------------------------*/
- /* Mark all symbols of the subtree having the current node as root*/
- /* for dragging. */
- /*----------------------------------------------------------------*/
-
- PutAllSubtreeSymAf(dhnd, employee_shnd, FALSE);
-
- /*----------------------------------------------------------------*/
- /* Remove the employee from its manager. */
- /*----------------------------------------------------------------*/
-
- RemoveEmployee(dhnd, employee_shnd);
-
- /*----------------------------------------------------------------*/
- /* Remove the manager from the employee. */
- /*----------------------------------------------------------------*/
-
- RemoveManager(dhnd, employee_shnd);
- }
-
- /*------------------------------------------------------------------*/
- /* If all employees are to be deleted, also the general manager has */
- /* to be removed from the company. */
- /*------------------------------------------------------------------*/
-
- RemoveGenManager(dhnd);
- return GS_YES;
- }