home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-12 | 6.9 KB | 242 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Commands.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef COMMANDS_H
- #define COMMANDS_H
-
- // ----- Framework Includes -----
-
- #ifndef FWCLPCMD_H
- #include "FWClpCmd.h"
- #endif
-
- #ifndef FWDRCMD_H
- #include "FWDrCmd.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class CIntlTestSelection;
- class CIntlTestSelectedContent;
- class CMyEditView;
- class FW_CEditView;
- class FW_CString;
-
- //========================================================================================
- // class CIntlTestDropCommand
- //========================================================================================
-
- class CIntlTestDropCommand : public FW_CDropCommand
- {
- public:
- FW_DECLARE_AUTO(CIntlTestDropCommand)
-
- CIntlTestDropCommand(Environment* ev,
- FW_CFrame* frame,
- FW_CEditView* dropView,
- CIntlTestSelection* selection,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint);
-
- virtual ~CIntlTestDropCommand();
-
- public:
- virtual void UndoIt(Environment* ev);
- virtual void RedoIt(Environment* ev);
- virtual void SaveUndoState(Environment* ev);
- virtual void SaveRedoState(Environment* ev);
-
- private:
- void SwapText(Environment* ev,
- FW_ByteCount bytesToRemove,
- const FW_CString& textToRestore);
-
- //----- Data Members -----
- private:
- FW_CEditView* fDropEditView;
- CIntlTestSelection* fTextSelection;
- // Saved data for undo/redo
- FW_CString fDroppedText;
- FW_CString fSavedText;
- short fSavedOffset;
- };
-
- //========================================================================================
- // class CIntlTestEditCommand
- //========================================================================================
- class CIntlTestEditCommand : public FW_CClipboardCommand
- {
- public:
- FW_DECLARE_AUTO(CIntlTestEditCommand)
-
- CIntlTestEditCommand(Environment* ev,
- ODCommandID commandID,
- FW_CFrame* frame,
- CIntlTestSelection* selection,
- FW_CEditView* editView,
- FW_Boolean canUndo);
-
- virtual ~ CIntlTestEditCommand();
-
- // ----- FW_CCommand overrides -----
- virtual void UndoIt(Environment* ev);
- virtual void RedoIt(Environment* ev);
- virtual void SaveUndoState(Environment* ev);
- virtual void SaveRedoState(Environment* ev);
-
- // ----- FW_CClipboardCommand overrides -----
- virtual void PreCommand(Environment* ev);
-
- private:
- void RemoveText(Environment* ev);
- void RestoreText(Environment* ev);
- void RemoveAndRestoreText(Environment* ev, FW_ByteCount bytesToRemove, const FW_CString& textToRestore);
-
- private:
- CIntlTestSelection* fTextSelection;
- FW_CEditView* fEditView;
- //--- Saved data for undo/redo
- FW_CString fPastedText;
- FW_CString fSavedText; // original text (Paste command)
- short fStartOffset;
- short fEndOffset;
- };
-
- //========================================================================================
- // class CTypingCommand
- //========================================================================================
-
- class CTypingCommand : public FW_CCommand
- {
- public:
- FW_DECLARE_AUTO(CTypingCommand)
-
- CTypingCommand(Environment* ev,
- ODCommandID commandID,
- FW_CFrame* frame,
- FW_CEditView* editView,
- FW_Boolean canUndo,
- char firstChar);
-
- virtual ~ CTypingCommand();
-
- // ----- FW_CCommand overrides -----
- virtual void DoIt(Environment* ev);
- virtual void UndoIt(Environment* ev);
- virtual void RedoIt(Environment* ev);
- virtual void SaveUndoState(Environment* ev);
- virtual void SaveRedoState(Environment* ev);
-
- // --- handling character input
- void AddCharacter(Environment* ev, char ch);
- void Backspace(Environment* ev, char bsChar);
- void CompleteTyping(Environment* ev);
- FW_Boolean IsNotCompleted();
-
- protected:
- FW_CEditView* fEditView;
- FW_Boolean fCompleted; // F: add further keystrokes to cmd
- private:
- char fFirstChar; // first character typed
- protected:
- //--- Saved data for undo/redo
- FW_CString fTypedText; // newly-typed string
- FW_CString fSavedText; // original string (typed over)
- short fStartOffset;
- short fEndOffset;
- };
-
- //-----------------------------------------------------------------------------------------
- inline FW_Boolean CTypingCommand::IsNotCompleted()
- {
- return !fCompleted;
- }
-
- //========================================================================================
- struct CTSMInput
- {
- char fByte; // either a single-byte char, like BS or CR
- char* fChars; // or confirmed chars from TSM
- FW_ByteCount fByteCount; // 0: use fByte; >0: use fChars
-
- CTSMInput(char ch) { fByte = ch; fChars = NULL; fByteCount = 0; }
- CTSMInput(char* chars, FW_ByteCount count)
- { fByte = 0; fChars = chars; fByteCount = count; }
- FW_Boolean IsMultiByte() { return fByteCount != 0; }
- };
-
- //========================================================================================
- // class CTSMTypingCommand
- //========================================================================================
-
- class CTSMTypingCommand : public CTypingCommand
- {
- public:
- FW_DECLARE_AUTO(CTSMTypingCommand)
-
- CTSMTypingCommand(Environment* ev,
- ODCommandID commandID,
- FW_CFrame* frame,
- FW_CEditView* editView,
- CTSMInput* firstInput);
-
- virtual ~ CTSMTypingCommand();
-
- // ----- FW_CCommand overrides -----
- virtual void DoIt(Environment* ev);
-
- public:
- // --- handling character input
- void AddInput(Environment* ev, CTSMInput* input);
- void Backspace(Environment* ev);
- FW_Boolean IsCompleted();
-
- private:
- CTSMInput* fFirstInput; // first characters input
- };
-
- //-----------------------------------------------------------------------------------------
- inline FW_Boolean CTSMTypingCommand::IsCompleted()
- {
- return fCompleted;
- }
-
- //========================================================================================
- // class CFontCommand - change font or font size (undoable)
- //========================================================================================
- class CFontCommand : public FW_CCommand
- {
- public:
- FW_DECLARE_AUTO(CFontCommand)
-
- CFontCommand(Environment* ev,
- ODCommandID commandID,
- FW_CFrame* frame,
- CMyEditView* editView);
-
- virtual ~ CFontCommand();
-
- // ----- FW_CCommand overrides -----
- virtual void DoIt(Environment* ev);
- virtual void UndoIt(Environment* ev);
- virtual void RedoIt(Environment* ev);
-
- private:
- FW_CFont fOldFont; // for Undo
- ODCommandID fOldFontCommand; // for Undo
- FW_CFont fNewFont; // for Redo
- CMyEditView* fEditView;
- FW_Boolean fNameChange; // F: font size change
- };
-
- #endif
-