home *** CD-ROM | disk | FTP | other *** search
-
-
- /*
- * These are implementations of functions to be called by a program (like Obsydian)
- * to implement functionality on the IDO.
- */
-
- #include <WINDOWS.H>
- #include "idoiface.h"
- #include "pvido.h"
-
-
-
- static char szDSLTextBuffer[500+1];
- static char szObjName[199+1];
-
-
- HINSTANCE IDO_LoadDLL()
- {
- HINSTANCE hIDOdll;
-
-
- #ifdef WIN32
- hIDOdll = LoadLibrary("pvido32.dll");
- #else
- hIDOdll = LoadLibrary("pvido.dll");
- #endif
- if(hIDOdll < HINSTANCE_ERROR)
- return 0;
- else
- return hIDOdll;
- }
- void IDO_FreeDLL(HINSTANCE hIDOdll)
- {
- FreeLibrary(hIDOdll);
- }
-
-
- HWND IDO_CreateInstance(HWND hDialog, HINSTANCE hApp, UINT id,
- int x, int y, int width, int height)
- {
- long lStyle = WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_TABSTOP;
- HWND hControl = 0;
-
- #ifdef WIN32
- hControl = CreateWindow("pvIDO32", "", lStyle, x, y, width, height, hDialog, (HMENU)id, hApp, NULL);
- #else
- hControl = CreateWindow("pvIDO", "", lStyle, x, y, width, height, hDialog, (HMENU)id, hApp, NULL);
- #endif
-
- return hControl;
- }
- BOOL IDO_DestroyInstance(HWND hIDO)
- {
- if(!IsWindow(hIDO))
- return FALSE;
-
- DestroyWindow(hIDO);
-
- return TRUE;
- }
-
-
- void IDO_Move(HWND hIDO, int x, int y, int width, int height)
- {
- if(!IsWindow(hIDO))
- return;
-
- SetWindowPos(hIDO, NULL, x, y,
- width, height,
- SWP_NOZORDER);
- }
-
- void IDO_ToggleUserIdoMenus(HWND hIDO)
- {
- if(!IsWindow(hIDO))
- return;
-
- if(idoGetPopupMenu(hIDO, IDOMENU_IDO))
- {
- idoSetPopupMenu(hIDO, IDOMENU_IDO, FALSE);
- idoSetPopupMenu(hIDO, IDOMENU_ENTITY, FALSE);
- idoSetPopupMenu(hIDO, IDOMENU_LINE, FALSE);
- }
- else
- {
- idoSetPopupMenu(hIDO, IDOMENU_IDO, TRUE);
- idoSetPopupMenu(hIDO, IDOMENU_ENTITY, TRUE);
- idoSetPopupMenu(hIDO, IDOMENU_LINE, TRUE);
- }
- }
-
- void IDO_ToggleEditMode(HWND hIDO)
- {
- if(!IsWindow(hIDO))
- return;
-
- if(idoGetEditMode(hIDO))
- idoSetEditMode(hIDO, FALSE);
- else
- idoSetEditMode(hIDO, TRUE);
- }
-
- void IDO_ToggleSnap(HWND hIDO)
- {
- if(!IsWindow(hIDO))
- return;
-
- if(idoGetSnapToGrid(hIDO))
- idoSetSnapToGrid(hIDO, FALSE);
- else
- idoSetSnapToGrid(hIDO, TRUE);
- }
-
- void IDO_ToggleGrid(HWND hIDO)
- {
- if(!IsWindow(hIDO))
- return;
-
- if(idoGetGridLines(hIDO))
- idoSetGridLines(hIDO, FALSE);
- else
- idoSetGridLines(hIDO, TRUE);
- }
-
-
- void IDO_TogglePalette(HWND hIDO)
- {
- if(!IsWindow(hIDO))
- return;
-
- if(idoGetToolsPalette(hIDO))
- idoSetToolsPalette(hIDO, FALSE);
- else
- idoSetToolsPalette(hIDO, TRUE);
- }
-
-
- void IDO_OpenJobFile(HWND hIDO, LPSTR lpszFile)
- {
- BOOL bEnforce;
-
- if(!IsWindow(hIDO))
- return;
-
- // were rules being enforced?
- bEnforce = idoGetRulesEnforced(hIDO);
- // turn off rules enforcement
- idoSetRulesEnforced(hIDO, FALSE);
- // read JOBS file
- SendMessage(hIDO, IDOM_READJOBSFILE, 0, (LPARAM)(LPSTR)lpszFile);
- // restore rules enforcement
- idoSetRulesEnforced(hIDO, TRUE);
- }
-
-
- void IDO_Redraw(HWND hIDO)
- {
- if(!IsWindow(hIDO))
- return;
-
- InvalidateRect(hIDO, NULL, TRUE);
- UpdateWindow(hIDO);
- }
-
-
- //***********************************************************************************
- //***********************************************************************************
-
- /*
- * These are implementations of functions to be called by a program (like Obsydian)
- * to respond to messages from the IDO.
- */
-
- //***********************************************************************************
- //***********************************************************************************
-
-
- void IDO_n_ClickRelation(HWND hIDO, long lFlag)
- {
- RELATION relation;
-
-
- if(!idoGetNotifyRelation(hIDO, &relation))
- return;
-
- switch(lFlag)
- {
- case NOTIFY_CLICK_LEFT :
- wsprintf(szDSLTextBuffer, "Line Left Clicked: %ld, %s.", relation.id, (LPSTR)relation.name);
- break;
- case NOTIFY_CLICK_LEFT_DBL :
- wsprintf(szDSLTextBuffer, "Line Left Dbl Clicked: %ld, %s.", relation.id, (LPSTR)relation.name);
- break;
- case NOTIFY_CLICK_RIGHT :
- wsprintf(szDSLTextBuffer, "Line Right Clicked: %ld, %s.", relation.id, (LPSTR)relation.name);
- break;
- case NOTIFY_CLICK_RIGHT_DBL :
- wsprintf(szDSLTextBuffer, "Line Right Dbl Clicked: %ld, %s.", relation.id, (LPSTR)relation.name);
- break;
- }
-
- DisplayDSL(szDSLTextBuffer);
- }
- void IDO_n_ClickEntity(HWND hIDO, long lFlag)
- {
- ENTITY entity;
-
-
- if(!idoGetNotifyEntity(hIDO, &entity))
- return;
-
- switch(lFlag)
- {
- case NOTIFY_CLICK_LEFT :
- wsprintf(szDSLTextBuffer, "Entity Left Clicked: %ld, %s.", entity.id, (LPSTR)entity.name);
- break;
- case NOTIFY_CLICK_LEFT_DBL :
- wsprintf(szDSLTextBuffer, "Entity Left Dbl Clicked: %ld, %s.", entity.id, (LPSTR)entity.name);
- break;
- case NOTIFY_CLICK_RIGHT :
- wsprintf(szDSLTextBuffer, "Entity Right Clicked: %ld, %s.", entity.id, (LPSTR)entity.name);
- break;
- case NOTIFY_CLICK_RIGHT_DBL :
- wsprintf(szDSLTextBuffer, "Entity Right Dbl Clicked: %ld, %s.", entity.id, (LPSTR)entity.name);
- break;
- }
-
- DisplayDSL(szDSLTextBuffer);
- }
- void IDO_n_ClickIDO(HWND hIDO, long lFlag)
- {
-
- switch(lFlag)
- {
- case NOTIFY_CLICK_LEFT :
- lstrcpy(szDSLTextBuffer, "IDO Left Clicked.");
- break;
- case NOTIFY_CLICK_LEFT_DBL :
- lstrcpy(szDSLTextBuffer, "IDO Left Dbl Clicked.");
- break;
- case NOTIFY_CLICK_RIGHT :
- lstrcpy(szDSLTextBuffer, "IDO Right Clicked.");
- break;
- case NOTIFY_CLICK_RIGHT_DBL :
- lstrcpy(szDSLTextBuffer, "IDO Right Dbl Clicked.");
- break;
- }
-
- DisplayDSL(szDSLTextBuffer);
- }
-
-
- void IDO_n_FileIO(UINT Msg, LPSTR lpszFile)
- {
- switch(Msg)
- {
- case IDOM_NOTIFY_BEFOREDIAGRAMLOADED :
- wsprintf(szDSLTextBuffer, "Before Diagram Loaded: %s", lpszFile);
- break;
- case IDOM_NOTIFY_DIAGRAMLOADED :
- wsprintf(szDSLTextBuffer, "Diagram Loaded: %s", lpszFile);
- break;
- case IDOM_NOTIFY_BEFOREDIAGRAMSAVED :
- wsprintf(szDSLTextBuffer, "Before Diagram Saved: %s", lpszFile);
- break;
- case IDOM_NOTIFY_DIAGRAMSAVED :
- wsprintf(szDSLTextBuffer, "Diagram Saved: %s", lpszFile);
- break;
- case IDOM_NOTIFY_BEFOREDIAGRAMRESET :
- wsprintf(szDSLTextBuffer, "Before Diagram Reset. %s", lpszFile);
- break;
- case IDOM_NOTIFY_DIAGRAMRESET :
- wsprintf(szDSLTextBuffer, "Diagram Reset. %s", lpszFile);
- break;
- case IDOM_NOTIFY_BEFOREPALETTELOADED :
- wsprintf(szDSLTextBuffer, "Before Palette Loaded: %s", lpszFile);
- break;
- case IDOM_NOTIFY_PALETTELOADED :
- wsprintf(szDSLTextBuffer, "Palette Loaded: %s", lpszFile);
- break;
- case IDOM_NOTIFY_BEFOREPALETTESAVED :
- wsprintf(szDSLTextBuffer, "Before Palette Saved: %s", lpszFile);
- break;
- case IDOM_NOTIFY_PALETTESAVED :
- wsprintf(szDSLTextBuffer, "Palette Saved: %s", lpszFile);
- break;
- case IDOM_NOTIFY_BEFOREPALETTERESET :
- wsprintf(szDSLTextBuffer, "Before Palette Reset. %s", lpszFile);
- break;
- case IDOM_NOTIFY_PALETTERESET :
- wsprintf(szDSLTextBuffer, "Palette Reset. %s", lpszFile);
- break;
- default :
- MessageBeep(0);
- break;
- }
- DisplayDSL(szDSLTextBuffer);
- }
-
- void IDO_n_DeleteRelationRequest(HWND hIDO, UINT uAllowed, LPLINE_CLASS_STRUCT lpLine)
- {
- wsprintf(szDSLTextBuffer, "Delete Relation?: %s, %s.", lpLine->name, lpLine->classname);
- DisplayDSL(szDSLTextBuffer);
-
- /*
- * If we don't want to delete the relation, send IDO_NOTIFY_NODELETERELATION,
- * else don't do a thing to delete the relation.
- */
- if(IDNO==MessageBox(NULL, szDSLTextBuffer, "Confirm Delete?", MB_YESNO | MB_ICONQUESTION))
- SendMessage(hIDO, IDOM_NOTIFYRESULT, 0, IDO_NOTIFY_NODELETERELATION);
- }
- void IDO_n_DeletedRelation(LPLINE_CLASS_STRUCT lpLine)
- {
- wsprintf(szDSLTextBuffer, "Deleted Relation: %s, %s.", lpLine->name, lpLine->classname);
- DisplayDSL(szDSLTextBuffer);
- }
-
- void IDO_n_AddRelationRequest(HWND hIDO, UINT uAllowed, LPLINE_CLASS_STRUCT lpRel)
- {
- wsprintf(szDSLTextBuffer, "Add Relation?: %s,%li <%s> %s,%li.", lpRel->Src_name, lpRel->Src_id,
- lpRel->classname,
- lpRel->Dst_name, lpRel->Dst_id);
- DisplayDSL(szDSLTextBuffer);
-
-
- /*
- * If the relation we wished to add did not exist, we are returned IDO_NOTIFY_NOADDRELATION.
- * We must override the default behavior to force the item to be added.
- *
- * If the relation we wished to add does exist, we are returned IDO_NOTIFY_ADDRELATION.
- * We must override the default behavior to prevent the item from being added.
- */
- if(uAllowed == IDO_NOTIFY_NOADDRELATION)
- {
- /*
- * If we don't want to add the relation, send IDO_NOTIFY_NOADDRELATION,
- * else don't do a thing to add the relation.
- */
- if(IDYES==MessageBox(NULL, szDSLTextBuffer, "Class or rule doesn't exist. Add anyway?", MB_YESNO | MB_ICONQUESTION))
- SendMessage(hIDO, IDOM_NOTIFYRESULT, 0, IDO_NOTIFY_ADDRELATION);
- }
- else
- {
- /*
- * If we don't want to add the relation, send IDO_NOTIFY_NOADDRELATION,
- * else don't do a thing to add the relation.
- */
- if(IDNO==MessageBox(NULL, szDSLTextBuffer, "Confirm add?", MB_YESNO | MB_ICONQUESTION))
- SendMessage(hIDO, IDOM_NOTIFYRESULT, 0, IDO_NOTIFY_NOADDRELATION);
- }
- }
- void IDO_n_AddedRelation(LPLINE_CLASS_STRUCT lpRel)
- {
- wsprintf(szDSLTextBuffer, "Relation added: %s,%li <%s> %s,%li.", lpRel->Src_name, lpRel->Src_id,
- lpRel->classname,
- lpRel->Dst_name, lpRel->Dst_id);
- DisplayDSL(szDSLTextBuffer);
- }
-
-
-
- void IDO_n_DeleteEntityRequest(HWND hIDO, UINT uAllowed, LPENTITY_CLASS_STRUCT lpEntity)
- {
- wsprintf(szDSLTextBuffer, "Delete Entity?: %s, %s.", lpEntity->name, lpEntity->classname);
- DisplayDSL(szDSLTextBuffer);
-
- /*
- * If we don't want to delete the entity, send IDO_NOTIFY_NODELETEENTITY,
- * else don't do a thing to delete the entity.
- */
- if(IDNO==MessageBox(NULL, szDSLTextBuffer, "Confirm Delete?", MB_YESNO | MB_ICONQUESTION))
- SendMessage(hIDO, IDOM_NOTIFYRESULT, 0, IDO_NOTIFY_NODELETEENTITY);
- }
- void IDO_n_DeletedEntity(LPENTITY_CLASS_STRUCT lpEntity)
- {
- wsprintf(szDSLTextBuffer, "Deleted Entity: %s, %s.", lpEntity->name, lpEntity->classname);
- DisplayDSL(szDSLTextBuffer);
- }
-
-
- void IDO_n_AddEntityRequest(HWND hIDO, UINT uAllowed, LPENTITY_CLASS_STRUCT lpEntity)
- {
- wsprintf(szDSLTextBuffer, "Add Entity?: %s, %s.", lpEntity->name, lpEntity->classname);
- DisplayDSL(szDSLTextBuffer);
-
-
- /*
- * If the class we wished to add did not exist, we are returned IDO_NOTIFY_NOADDENTITY.
- * We must override the default behavior to force the item to be added.
- *
- * If the class we wished to add does exist, we are returned IDO_NOTIFY_ADDENTITY.
- * We must override the default behavior to prevent the item from being added.
- */
- if(uAllowed == IDO_NOTIFY_NOADDENTITY)
- {
- /*
- * If we don't want to add the entity, send IDO_NOTIFY_NOADDENTITY,
- * else don't do a thing to add the entity.
- */
- if(IDYES==MessageBox(NULL, szDSLTextBuffer, "Class doesn't exist. Add anyway?", MB_YESNO | MB_ICONQUESTION))
- SendMessage(hIDO, IDOM_NOTIFYRESULT, 0, IDO_NOTIFY_ADDENTITY);
- }
- else
- {
- /*
- * If we don't want to add the entity, send IDO_NOTIFY_NOADDENTITY,
- * else don't do a thing to add the entity.
- */
- if(IDNO==MessageBox(NULL, szDSLTextBuffer, "Confirm add?", MB_YESNO | MB_ICONQUESTION))
- SendMessage(hIDO, IDOM_NOTIFYRESULT, 0, IDO_NOTIFY_NOADDENTITY);
- }
- }
- void IDO_n_AddedEntity(LPENTITY_CLASS_STRUCT lpEntity)
- {
- wsprintf(szDSLTextBuffer, "Added Entity: %s, %s.", lpEntity->name, lpEntity->classname);
- DisplayDSL(szDSLTextBuffer);
- }
-
-
- void IDO_n_InvalidEditEvent()
- {
- wsprintf(szDSLTextBuffer, "Cannot perform action: not in Edit mode.");
- DisplayDSL(szDSLTextBuffer);
- }
-
-
-
-