home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-12 | 8.1 KB | 258 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: EditViews.h
- // Release Version: $ ODF 2 $
- //
- // Author: Mary Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef EDITVIEWS_H
- #define EDITVIEWS_H
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- // ----- ODF Includes -----
-
- #ifndef FWEDVIEW_H
- #include "FWEdView.h"
- #endif
-
- #ifndef FWSCPTBL_H
- #include "FWScptbl.h"
- #endif
-
- #ifndef FWPULLDM_H
- #include "FWPullDM.h"
- #endif
-
- // ----- Macintosh Includes -----
-
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
-
- #ifndef __TEXTSERVICES__
- #include <TextServices.h>
- #endif
-
- #ifndef __TSMTE__
- #include <TSMTe.h>
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class CIntlTestPart;
- class FW_CViewContext;
- class FW_CMouseEvent;
- class FW_CClipboardCommand;
- class CTypingCommand;
- class CTSMTypingCommand;
-
- //========================================================================================
- // Constants and Globals
- //========================================================================================
-
- extern FW_CFont gFontOsaka; // Default Japanese font
-
- extern ODMenuID gSizeMenuID; // the Size menu's ID
- extern FW_CPullDownMenu* gFontMenu; // the current Font menu
- extern short gFontCount; // number of items in the current Font menu
-
- extern FW_CPullDownMenu* gDefaultFontMenu; // default Font menu (Roman fonts only)
- extern FW_CPullDownMenu* gJFontMenu; // Japanese Font menu
-
- const FW_Message kEditViewMsg = 45; // ASCII 'E'
-
- //----------------------------------------------------------------------------------------
- // Enumeration for ASCII Character Constants - copied from MacApp
- //----------------------------------------------------------------------------------------
-
- enum EAsciiControlCode {
- chBackspace = 8, // ASCII code for Backspace character
- chClear = 27, // ASCII code for Clear key (aka ESC)
- chDown = 31, // ASCII code for down arrow
- chEnd = 4, // ASCII code for the End key
- chEnter = 3, // ASCII code for Enter character
- chEscape = 27, // ASCII code for Escape (aka Clear) key
- chFunction = 16, // ASCII code for any function key
- chFwdDelete = 127, // ASCII code for forward delete
- chHelp = 5, // ASCII code for Help key
- chHome = 1, // ASCII code for the Home key
- chLeft = 28, // ASCII code for left arrow
- chPageDown = 12, // ASCII code for Page Down key
- chPageUp = 11, // ASCII code for Page Up key
- chReturn = 13, // ASCII code for Return character
- chRight = 29, // ASCII code for right arrow
- chSpace = 32, // ASCII code for Space character
- chTab = 9, // ASCII code for Tab character
- chUp = 30 // ASCII code for up arrow
- };
-
- //========================================================================================
- // FW_MTSMHandler - a mixin for views that use the Text Services Manager
- //========================================================================================
- class FW_MTSMHandler
- {
- public:
- FW_DECLARE_CLASS
-
- FW_MTSMHandler(FW_CEditView* theView);
- virtual ~FW_MTSMHandler();
-
- FW_Boolean CreateTSMDocument(TEHandle te);
-
- FW_Boolean DoActivateTSM(FW_Boolean becomingActive);
- FW_Boolean DoFixTSMDocument();
-
- TSMDocumentID GetTSMDocument() const;
- void SetTSMDocument(TSMDocumentID docId);
-
- private:
- TSMDocumentID fTSMDocId;
- TSMTERecHandle fTSMHandle;
- FW_CEditView* fEditView;
- OSErr fError; // error from last TSM call
- };
-
- //----------------------------------------------------------------------------------------
- inline TSMDocumentID FW_MTSMHandler::GetTSMDocument() const
- {
- return fTSMDocId;
- }
-
- //----------------------------------------------------------------------------------------
- inline void FW_MTSMHandler::SetTSMDocument(TSMDocumentID docId)
- {
- fTSMDocId = docId;
- }
-
- //========================================================================================
- // CMyEditView - experiment with typing Undo/Redo
- //========================================================================================
- class CMyEditView : public FW_CEditView
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(CMyEditView)
-
- public:
- CMyEditView(Environment* ev,
- FW_CSuperView* container,
- const FW_CRect& bounds,
- ODID viewId,
- const FW_CFont& font,
- short maxChars,
- unsigned short attributes);
-
- CMyEditView(Environment* ev); // default constructor
- virtual ~ CMyEditView();
-
- public:
- // ----- Events -----
- virtual void ActivateTarget(Environment* ev, FW_Boolean tabSelection);
- virtual void DeactivateTarget(Environment* ev);
- virtual FW_Handled DoAdjustMenus(Environment* ev,
- FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot);
- virtual FW_Handled DoCharKey(Environment* ev, const FW_CCharKeyEvent& event);
- virtual FW_Handled DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
- virtual FW_Handled DoMouseDown(Environment* ev, const FW_CMouseEvent& event);
-
- // ----- Archiving -----
- static void* Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
- static void Destroy(void* object, FW_ClassTypeConstant type);
- virtual void Flatten(Environment* ev, FW_CWritableStream& stream) const;
- virtual void InitializeFromStream(Environment* ev, FW_CReadableStream& stream);
-
- virtual void PostCreateViewFromStream(Environment* ev);
-
- // ----- New Stuff -----
- void CommandToString(Environment* ev, ODCommandID id, FW_CString& string);
- void DoSetFont(Environment* ev, ODCommandID id, const FW_CString& fontName);
- void DoSetFontSize(Environment* ev, int fontSize);
- FW_CFont GetCurrentFont();
- ODCommandID GetCurrentFontCmd(Environment* ev);
-
- void TypingCommandAboutToBeDestroyed(CTypingCommand* cmd);
-
- protected:
- FW_CMenuBar* GetMenuBar(Environment* ev);
- ODCommandID GetCurrentSizeCmd();
-
- virtual FW_CPullDownMenu* GetMyFontMenu();
-
- void DoneTyping(Environment* ev);
- FW_Boolean IsArrowKey(char ch);
-
- private:
- CTypingCommand* NewTypingCommand(Environment* ev, char firstChar);
-
- protected:
- CTypingCommand* fTypingCommand;
- FW_CString fFontName; // name of current font
- ODCommandID fFontCmd; // current font command id
- int fFontSize; // current font size
- };
-
- //========================================================================================
- // CJEditView
- //========================================================================================
- class CJEditView : public CMyEditView, public FW_MTSMHandler
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(CJEditView)
-
- public:
- CJEditView(Environment* ev,
- FW_CSuperView* container,
- const FW_CRect& bounds,
- ODID viewId,
- const FW_CFont& font,
- short maxChars,
- unsigned short attributes);
- CJEditView(Environment* ev);
- virtual ~ CJEditView();
-
- void InitJEditView(Environment* ev);
- virtual void PostCreateViewFromStream(Environment* ev);
-
- public:
- virtual void ActivateTarget(Environment* ev, FW_Boolean tabSelection);
- virtual void DeactivateTarget(Environment* ev);
-
- virtual FW_Handled DoCharKey(Environment* ev, const FW_CCharKeyEvent& event);
- virtual FW_Handled DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
-
- // ----- Archiving -----
- static void* Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
- static void Destroy(void* object, FW_ClassTypeConstant type);
-
- public:
- void AddInput(Environment* ev, CTSMInput* input);
- void DoMakeTypingCommand(Environment* ev = NULL);
- FW_Boolean IsFirstEventInSequence();
-
- protected:
- virtual FW_CPullDownMenu* GetMyFontMenu();
-
- private:
- CTSMTypingCommand* NewTypingCommand(Environment* ev, CTSMInput* firstInput);
- CTSMTypingCommand* fTSMTypingCommand;
-
- private:
- short fMyFont; // my font
- short fMyFontScript; // my font's script
- short fPreviousFontScript; // font script saved on activation, restored on deactivation
- };
-
-
- #endif