home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / ZINC_6.ZIP / DOSSRC.ZIP / D_CTRL2.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  3.0 KB  |  117 lines

  1. //    Zinc Interface Library - D_CTRL2.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #include "ui_dsn.hpp"
  6. #include "d_help.hlh"
  7. #include <fcntl.h>
  8. #include <stdio.h>
  9. #include <sys\stat.h>
  10.  
  11. void UI_DESIGN_MANAGER::EditControl(void *data, UI_EVENT &event)
  12. {
  13.     const char *pasteName = "paste";
  14.  
  15.     // Make sure there is a current object.
  16.     UIW_POP_UP_ITEM *item = (UIW_POP_UP_ITEM *)data;
  17.     if (!_currentObject && item->value != EDIT_PASTE)
  18.     {
  19.         _errorSystem->Beep();
  20.         return;
  21.     }
  22.  
  23.     // Switch on the item type.
  24.     event.type = 0;
  25.     switch (item->value)
  26.     {
  27.     case EDIT_OBJECT:
  28.         event.type = S_EDIT_OBJECT;
  29.         break;
  30.  
  31.     case EDIT_PASTE:
  32.         char fullPath[64];
  33.         UI_STORAGE::AppendFullPath(fullPath, UI_DESIGN_MANAGER::originalDirectory, pasteName);
  34.         UI_STORAGE::ChangeExtension(fullPath, ".DAT");
  35.         if (UI_STORAGE::ValidName(fullPath, FALSE))
  36.         {
  37.             UI_STORAGE *file = new UI_STORAGE(fullPath, TRUE);
  38.             UI_STORAGE_ELEMENT *element = file->Seek(pasteName);
  39.             if (element)
  40.             {
  41.                 UI_WINDOW_OBJECT *(*newFunction)(const char *name, UI_STORAGE *file, USHORT loadFlags);
  42.                 UI_JUMP_LIST::_jumpList.GetFunction(element->search.type, &newFunction);
  43.                 _currentObject = newFunction(element->search.stringID, file, L_NO_FLAGS);
  44.                 event.type = S_PLACE_OBJECT;
  45.                 item->eventManager->Put(event, Q_BEGIN);
  46.                 event.type = S_CLOSE_TEMPORARY;
  47.                 delete file;
  48.             }
  49.             else
  50.                 _errorSystem->Beep();
  51.         }
  52.         else
  53.             _errorSystem->Beep();
  54.         break;
  55.  
  56.     case EDIT_CUT:
  57.     case EDIT_COPY:
  58.         {
  59.         char fullPath[128];
  60.         UI_STORAGE::AppendFullPath(fullPath, UI_DESIGN_MANAGER::originalDirectory, pasteName);
  61.         UI_STORAGE::ChangeExtension(fullPath, ".DAT");
  62.         remove(fullPath);
  63.         UI_STORAGE *file = new UI_STORAGE(fullPath, TRUE);
  64.         _currentObject->Store(pasteName, file);
  65.         file->Save();
  66.         delete file;
  67.         if (item->value == EDIT_COPY)
  68.         {
  69.             event.type = S_CLOSE_TEMPORARY;
  70.             break;
  71.         }
  72.         }
  73.         // Continue to EDIT_DELETE.
  74.  
  75.     case EDIT_DELETE:
  76.         if (_storage && !_currentObject->parent)
  77.         {
  78.             UI_STORAGE_ELEMENT *element = _storage->Seek(_currentObject->StringID());
  79.             if (element)
  80.                 _storage->Subtract(element);
  81.             extern int _resourceRecompute;
  82.             _resourceRecompute = TRUE;
  83.         }
  84.         // Continue to EDIT_CLEAR.
  85.  
  86.     case EDIT_CLEAR:
  87.         event.type = S_CLEAR_OBJECT;
  88.          item->eventManager->Put(event, Q_BEGIN);
  89.         event.type = S_CLOSE_TEMPORARY;
  90.         break;
  91.  
  92.     case EDIT_MOVE:
  93.     case EDIT_SIZE:
  94.         if (item->value == EDIT_MOVE)
  95.         {
  96.             event.type = S_MOVE_CURRENT;
  97.             event.position.column = _currentObject->true.left;
  98.             event.position.line = _currentObject->true.top;
  99.         }
  100.         else
  101.         {
  102.             event.type = S_SIZE_CURRENT;
  103.             event.rawCode = M_RIGHT_CHANGE | M_BOTTOM_CHANGE;
  104.             event.position.column = _currentObject->true.right;
  105.             event.position.line = _currentObject->true.bottom;
  106.         }
  107.          item->eventManager->Put(event, Q_BEGIN);
  108.         event.type = S_CLOSE_TEMPORARY;
  109.         break;
  110.     }
  111.  
  112.     // Process any new events.
  113.     if (event.type)
  114.          item->eventManager->Put(event, Q_BEGIN);
  115. }
  116.  
  117.