home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-26 | 9.1 KB | 301 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Commands.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFx.hpp"
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfx
- #endif
-
- FW_DEFINE_AUTO(CODFxEditCommand)
- FW_DEFINE_AUTO(CODFxDropCommand)
- FW_DEFINE_AUTO(CODFxDragCommand)
-
- //========================================================================================
- // CODFxEditCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand constructor
- //----------------------------------------------------------------------------------------
-
- CODFxEditCommand::CODFxEditCommand(Environment* ev,
- ODCommandID id,
- CODFxContent* itsContent,
- FW_CFrame* frame) :
- FW_CClipboardCommand(ev, id, frame, FW_kCanUndo),
- fODFxContent(itsContent),
- fSavedData(false)
- {
- switch (id)
- {
- case kODCommandCut: // we do something strange: we reset the colors when clear or cut is chosen
- SetMenuStringsFromResource(ev, kODFxUndoStrings, kUndoResetMsg, kRedoResetMsg);
- break;
- case kODCommandClear:
- SetMenuStringsFromResource(ev, kODFxUndoStrings, kUndoResetMsg, kRedoResetMsg);
- break;
- case kODCommandPaste:
- SetMenuStringsFromResource(ev, kODFxUndoStrings, kUndoPasteMsg, kRedoPasteMsg);
- break;
- }
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand destructor
- //----------------------------------------------------------------------------------------
-
- CODFxEditCommand::~CODFxEditCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
-
- void CODFxEditCommand::SaveUndoState(Environment *ev)
- {
- FW_UNUSED(ev);
- fODFxContent->GetContentData(fSavedData);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CODFxEditCommand::UndoIt(Environment* ev)
- {
- FW_CClipboardCommand::UndoIt(ev); // call inherited
-
- switch (GetCommandID(ev))
- {
- case kODCommandCut:
- case kODCommandClear:
- this->RestoreSelection(ev);
- break;
-
- case kODCommandPaste:
- this->SwapSelection(ev);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CODFxEditCommand::RedoIt(Environment *ev)
- {
- FW_CClipboardCommand::RedoIt(ev); // call inherited
-
- switch (GetCommandID(ev))
- {
- // case kODCommandCut:
- case kODCommandClear:
- this->RemoveSelection(ev);
- break;
-
- case kODCommandPaste:
- this->SwapSelection(ev);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand::RemoveSelection
- //----------------------------------------------------------------------------------------
-
- void CODFxEditCommand::RemoveSelection(Environment* ev)
- {
- fODFxContent->ResetColorData(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand::RestoreSelection
- //----------------------------------------------------------------------------------------
-
- void CODFxEditCommand::RestoreSelection(Environment* ev)
- {
- fODFxContent->SetContentData(ev, fSavedData);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxEditCommand::SwapSelection
- //----------------------------------------------------------------------------------------
-
- void CODFxEditCommand::SwapSelection(Environment* ev)
- {
- CODFxContent::ODFXContentStruct tempData(false);
-
- fODFxContent->GetContentData(tempData);
-
- fODFxContent->SetContentData(ev, fSavedData);
-
- fSavedData = tempData;
- }
-
- //========================================================================================
- // CODFxDragCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CODFxDragCommand constructor
- //----------------------------------------------------------------------------------------
-
- CODFxDragCommand::CODFxDragCommand(Environment* ev,
- CODFxContent* content,
- FW_CFrame* frame) :
- FW_CDragCommand(ev, frame, FW_kCantUndo),
- fODFxContent(content),
- fSavedData(false)
- {
- // SetMenuStringsFromResource(ev, kODFxUndoStrings, kUndoDragMsg, kRedoDragMsg);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDragCommand destructor
- //----------------------------------------------------------------------------------------
-
- CODFxDragCommand::~CODFxDragCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDragCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
-
- void CODFxDragCommand::SaveUndoState(Environment *ev) // Override
- {
- FW_UNUSED(ev);
- // fSavedNumColors = fODFxContent->GetNumColors();
- // fODFxContent->GetColorData(fSavedColors);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDragCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CODFxDragCommand::UndoIt(Environment* ev)
- {
- // fODFxContent->SetColorData(ev, fSavedColors);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDragCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CODFxDragCommand::RedoIt(Environment* ev)
- {
- // fODFxContent->ResetColorData(ev);
- }
-
- //========================================================================================
- // CODFxDropCommand
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CODFxDropCommand constructor
- //----------------------------------------------------------------------------------------
-
- CODFxDropCommand::CODFxDropCommand(Environment *ev,
- CODFxContent* content,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint) :
- FW_CDropCommand(ev, frame, dropInfo, odFacet, dropPoint, FW_kCanUndo),
- fODFxContent(content),
- fSavedData(false)
- {
- SetMenuStringsFromResource(ev, kODFxUndoStrings, kUndoDropMsg, kRedoDropMsg);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDropCommand destructor
- //----------------------------------------------------------------------------------------
-
- CODFxDropCommand::~CODFxDropCommand()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDropCommand::SaveUndoState
- //----------------------------------------------------------------------------------------
-
- void CODFxDropCommand::SaveUndoState(Environment *ev)
- {
- FW_UNUSED(ev);
- fODFxContent->GetContentData(fSavedData);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDropCommand::UndoIt
- //----------------------------------------------------------------------------------------
-
- void CODFxDropCommand::UndoIt(Environment* ev)
- {
- this->SwapSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDropCommand::RedoIt
- //----------------------------------------------------------------------------------------
-
- void CODFxDropCommand::RedoIt(Environment* ev)
- {
- this->SwapSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CODFxDropCommand::SwapSelection
- //----------------------------------------------------------------------------------------
-
- void CODFxDropCommand::SwapSelection(Environment* ev)
- {
- CODFxContent::ODFXContentStruct tempData(false);
-
- fODFxContent->GetContentData(tempData);
-
- fODFxContent->SetContentData(ev, fSavedData);
-
- fSavedData = tempData;
- }
-
-