home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - D_CTRL2.CPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #include "ui_dsn.hpp"
- #include "d_help.hlh"
- #include <fcntl.h>
- #include <stdio.h>
- #include <sys\stat.h>
-
- void UI_DESIGN_MANAGER::EditControl(void *data, UI_EVENT &event)
- {
- const char *pasteName = "paste";
-
- // Make sure there is a current object.
- UIW_POP_UP_ITEM *item = (UIW_POP_UP_ITEM *)data;
- if (!_currentObject && item->value != EDIT_PASTE)
- {
- _errorSystem->Beep();
- return;
- }
-
- // Switch on the item type.
- event.type = 0;
- switch (item->value)
- {
- case EDIT_OBJECT:
- event.type = S_EDIT_OBJECT;
- break;
-
- case EDIT_PASTE:
- char fullPath[64];
- UI_STORAGE::AppendFullPath(fullPath, UI_DESIGN_MANAGER::originalDirectory, pasteName);
- UI_STORAGE::ChangeExtension(fullPath, ".DAT");
- if (UI_STORAGE::ValidName(fullPath, FALSE))
- {
- UI_STORAGE *file = new UI_STORAGE(fullPath, TRUE);
- UI_STORAGE_ELEMENT *element = file->Seek(pasteName);
- if (element)
- {
- UI_WINDOW_OBJECT *(*newFunction)(const char *name, UI_STORAGE *file, USHORT loadFlags);
- UI_JUMP_LIST::_jumpList.GetFunction(element->search.type, &newFunction);
- _currentObject = newFunction(element->search.stringID, file, L_NO_FLAGS);
- event.type = S_PLACE_OBJECT;
- item->eventManager->Put(event, Q_BEGIN);
- event.type = S_CLOSE_TEMPORARY;
- delete file;
- }
- else
- _errorSystem->Beep();
- }
- else
- _errorSystem->Beep();
- break;
-
- case EDIT_CUT:
- case EDIT_COPY:
- {
- char fullPath[128];
- UI_STORAGE::AppendFullPath(fullPath, UI_DESIGN_MANAGER::originalDirectory, pasteName);
- UI_STORAGE::ChangeExtension(fullPath, ".DAT");
- remove(fullPath);
- UI_STORAGE *file = new UI_STORAGE(fullPath, TRUE);
- _currentObject->Store(pasteName, file);
- file->Save();
- delete file;
- if (item->value == EDIT_COPY)
- {
- event.type = S_CLOSE_TEMPORARY;
- break;
- }
- }
- // Continue to EDIT_DELETE.
-
- case EDIT_DELETE:
- if (_storage && !_currentObject->parent)
- {
- UI_STORAGE_ELEMENT *element = _storage->Seek(_currentObject->StringID());
- if (element)
- _storage->Subtract(element);
- extern int _resourceRecompute;
- _resourceRecompute = TRUE;
- }
- // Continue to EDIT_CLEAR.
-
- case EDIT_CLEAR:
- event.type = S_CLEAR_OBJECT;
- item->eventManager->Put(event, Q_BEGIN);
- event.type = S_CLOSE_TEMPORARY;
- break;
-
- case EDIT_MOVE:
- case EDIT_SIZE:
- if (item->value == EDIT_MOVE)
- {
- event.type = S_MOVE_CURRENT;
- event.position.column = _currentObject->true.left;
- event.position.line = _currentObject->true.top;
- }
- else
- {
- event.type = S_SIZE_CURRENT;
- event.rawCode = M_RIGHT_CHANGE | M_BOTTOM_CHANGE;
- event.position.column = _currentObject->true.right;
- event.position.line = _currentObject->true.bottom;
- }
- item->eventManager->Put(event, Q_BEGIN);
- event.type = S_CLOSE_TEMPORARY;
- break;
- }
-
- // Process any new events.
- if (event.type)
- item->eventManager->Put(event, Q_BEGIN);
- }
-
-