home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / Composer / CEditView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  9.5 KB  |  273 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #pragma once
  20.  
  21. #include <TextServices.h>
  22. #include "CHTMLView.h"
  23.  
  24. // dangling prototype
  25. Boolean GetCaretPosition(MWContext *context, LO_Element * element, int32 caretPos, 
  26.                                     int32* caretX, int32* caretYLow, int32* caretYHigh );
  27.  
  28.  
  29. class LGAPopup;
  30. class CPatternButtonPopup;
  31. class CColorPopup;
  32. class CComposeSession;
  33. class CFontMenuPopup;
  34.  
  35. class HTMLInlineTSMProxy;
  36. class HoldUpdatesProxy;
  37.  
  38. class CEditView: public CHTMLView
  39. {
  40. #if !defined(__MWERKS__) || (__MWERKS__ >= 0x2000)
  41.     typedef CHTMLView inherited;
  42. #endif
  43.  
  44. public:
  45.     enum { pane_ID = 'html', class_ID = 'Edtp', dashMark = '-' };
  46.     enum {
  47.             STRPOUND_EDITOR_MENUS            = 5101,
  48.             EDITOR_MENU_SHOW_PARA_SYMBOLS        = 1,
  49.             EDITOR_MENU_HIDE_PARA_SYMBOLS        = 2,
  50.             EDITOR_MENU_UNDO                    = 3,
  51.             EDITOR_MENU_REDO                    = 4,
  52.             EDITOR_MENU_SHOW_COMP_TOOLBAR        = 5,
  53.             EDITOR_MENU_HIDE_COMP_TOOLBAR        = 6,
  54.             EDITOR_MENU_SHOW_FORMAT_TOOLBAR        = 7,
  55.             EDITOR_MENU_HIDE_FORMAT_TOOLBAR        = 8,
  56.             EDITOR_MENU_SHOW_TABLE_BORDERS        = 9,
  57.             EDITOR_MENU_HIDE_TABLE_BORDERS        = 10,
  58.             EDITOR_MENU_CHARACTER_ATTRIBS        = 11,
  59.             EDITOR_MENU_IMAGE_ATTRIBUTES        = 12,
  60.             EDITOR_MENU_LINK_ATTRIBUTES            = 13,
  61.             EDITOR_MENU_LINE_ATTRIBUTES            = 14,
  62.             EDITOR_MENU_TABLE_ATTRIBUTES        = 15,
  63.             EDITOR_MENU_UNKNOWN_ATTRIBUTES        = 16,
  64.             EDITOR_MENU_TARGET_ATTRIBUTES        = 17
  65.     };
  66.     enum {
  67.             eMouseHysteresis = 6,
  68.             eSelectionBorder = 3
  69.     };
  70.     
  71.     // ÑÑ Constructors
  72.                     CEditView(LStream * inStream);
  73.                     ~CEditView();
  74.     virtual void    FinishCreateSelf(void);
  75.  
  76.     // ÑÑ Command handling
  77.     virtual    Boolean ObeyCommand( CommandT inCommand, void *ioParam );
  78.     virtual void    ListenToMessage( MessageT inMessage, void* ioParam );
  79.     virtual void      FindCommandStatus( CommandT inCommand,
  80.                             Boolean& outEnabled, Boolean& outUsesMark, 
  81.                             Char16& outMark,Str255 outName );
  82.             Boolean    FindCommandStatusForContextMenu( CommandT inCommand,
  83.                             Boolean &outEnabled, Boolean &outUsesMark,
  84.                             Char16 &outMark, Str255 outName );
  85.     
  86.             Boolean IsPastable(Char16 theChar);
  87.             int     FindQueuedKeys( char *keys_in_q );
  88.     virtual Boolean HandleKeyPress( const EventRecord& inKeyEvent );
  89.     
  90.     virtual void     AdaptToSuperFrameSize( Int32 inSurrWidthDelta, 
  91.                                             Int32 inSurrHeightDelta, Boolean inRefresh );
  92.                                 
  93.     virtual void    BeTarget();
  94.     virtual void    DontBeTarget();
  95.  
  96.             void    HandleCut();
  97.             void    HandleCopy();
  98.             void    HandlePaste();
  99.     
  100.     TSMDocumentID    midocID;
  101.     
  102.     virtual void    CreateFindWindow();
  103.     virtual void    SetContext( CBrowserContext* inNewContext );
  104.     virtual URL_Struct *GetURLForPrinting( Boolean& outSuppressURLCaption, MWContext *printingContext );
  105.  
  106.     void            TakeOffDuty();
  107.     virtual void    PutOnDuty(LCommander*);
  108.     
  109.     Bool             PtInSelectedRegion(SPoint32 cpPoint );
  110.     virtual void    DrawSelf( void );
  111.     virtual Boolean    EstablishPort();
  112.     virtual void     ActivateSelf();
  113.     virtual void     DeactivateSelf();
  114.     
  115.     Bool            SaveDocument();
  116.     Bool            SaveDocumentAs();
  117.     Bool            VerifySaveUpToDate();
  118.     
  119.  
  120.     // ÑÑ cursor calls and caret functionality
  121.     virtual void    AdjustCursorSelf( Point inPortPt, const EventRecord& inMacEvent );
  122.  
  123.     virtual void    SpendTime( const EventRecord& inMacEvent );
  124.     void             DrawCaret( Boolean doErase );
  125.     void             EraseCaret();
  126.     void            HideCaret( Boolean mhide ) { EraseCaret(); mHideCaret = mhide; }
  127.     void            PlaceCaret(int32 caretX, int32 caretYLow, int32 caretYHigh);
  128.     void            RemoveCaret();
  129.     void             DisplayGenericCaret( MWContext *context, LO_Element * pLoAny, 
  130.                                         ED_CaretObjectPosition caretPos );
  131.     
  132.     // ÑÑ Drag and Drop 
  133.     virtual Boolean    ItemIsAcceptable (DragReference    dragRef, ItemReference itemRef);
  134.     virtual void    ReceiveDragItem( DragReference inDragRef, DragAttributes inDragAttr, 
  135.                                     ItemReference inItemRef, Rect& inItemBounds );
  136.     virtual void    DoDragSendData( FlavorType inFlavor, ItemReference inItemRef,
  137.                                     DragReference inDragRef );
  138.     
  139.     virtual void    ClickSelf (const SMouseDownEvent& where );
  140.     virtual    Boolean    ClickTrackSelection( const SMouseDownEvent&    inMouseDown, 
  141.                                         CHTMLClickRecord& inClickRecord );
  142.     
  143.     virtual Boolean    SetDefaultCSID( Int16 inPreferredCSID );
  144.     CBrowserContext    *GetNSContext() { return mContext; };
  145.  
  146.     void            SetHoldUpdates(HoldUpdatesProxy* inHoldUpdates) {mHoldUpdates = inHoldUpdates;};
  147.  
  148.     Boolean            mEditorDoneLoading;
  149.     Boolean            IsDoneLoading() const { return mEditorDoneLoading; }
  150.  
  151.     // ÑÑ FE_* calls
  152.     void            DocumentChanged( int32 iStartY, int32 iHeight );
  153.     void            GetDocAndWindowPosition( SPoint32 &frameLocation, SPoint32 &imageLocation, SDimension16 &frameSize );
  154.     
  155.     // ÑÑ formatting query calls
  156.     void            UseCharFormattingCache() { CanUseCharFormatting(); mUseCharFormattingCache = true; }
  157.     void            DontUseCharFormattingCache() { mUseCharFormattingCache = false; }
  158.  
  159.     class StUseCharFormattingCache
  160.     {
  161.         public:
  162.             StUseCharFormattingCache( CEditView& p ) : view(p) { view.UseCharFormattingCache(); }
  163.             ~StUseCharFormattingCache() { view.DontUseCharFormattingCache(); }
  164.         
  165.         private:
  166.             CEditView &view;    
  167.     };
  168.  
  169.     LGAPopup        * mParagraphToolbarPopup;
  170.     LGAPopup        * mSizeToolbarPopup;
  171.     CFontMenuPopup    * mFontToolbarPopup;
  172.     CPatternButtonPopup    * mAlignToolbarPopup;
  173.     CColorPopup        * mColorPopup;
  174.  
  175. protected:
  176.     virtual Boolean        IsGrowCachingEnabled() const { return !mEditorDoneLoading; }
  177.  
  178.     virtual void         LayoutNewDocument( URL_Struct *inURL, Int32 *inWidth,
  179.                                         Int32 *inHeight, Int32 *inMarginWidth, Int32 *inMarginHeight );
  180.  
  181.     // ÑÑ FE_* calls
  182.     virtual void         SetDocPosition( int inLocation, Int32 inX, Int32 inY,
  183.                                     Boolean inScrollEvenIfVisible = false);
  184.     virtual void         DisplayLineFeed( int inLocation, LO_LinefeedStruct *inLinefeedStruct, XP_Bool inNeedBG );
  185.     virtual void         DisplayHR( int inLocation, LO_HorizRuleStruct *inRuleStruct );
  186.     virtual void         DisplaySubtext( int inLocation, LO_TextStruct *inText, 
  187.                                         Int32 inStartPos, Int32 inEndPos, XP_Bool inNeedBG );
  188.     virtual void         EraseBackground( int inLocation, Int32 inX, Int32 inY,
  189.                                         Uint32 inWidth, Uint32 inHeight, LO_Color *inColor );
  190.     virtual void        GetDefaultBackgroundColor(LO_Color* outColor) const;
  191.     virtual void         DisplayTable( int inLocation, LO_TableStruct *inTableStruct );
  192.     virtual void        DisplayCell( int inLocation, LO_CellStruct *inCellStruct );
  193.     virtual    void         InvalidateEntireTableOrCell( LO_Element* inElement );
  194.     virtual    void         DisplayAddRowOrColBorder( XP_Rect* inRect, XP_Bool inDoErase );
  195.     virtual void        UpdateEnableStates();
  196.     virtual void        DisplayFeedback( int inLocation, LO_Element *inElement );
  197.     virtual void        DisplaySelectionFeedback( uint16 ele_attrmask, const Rect &inRect );
  198.     
  199.     
  200.     virtual void        InsideDropArea( DragReference inDragRef );
  201.     virtual void         EnterDropArea( DragReference inDragRef, Boolean inDragHasLeftSender );
  202.     DragReference         mDragRef;
  203.  
  204.     enum {
  205.         ED_SELECTION_BORDER = 3
  206.         };
  207.     
  208.     enum { MAX_Q_SIZE = 12 };        // Used for checking out key strokes waiting in FindQueuedKeys
  209.  
  210.     void             InsertDefaultLine();
  211.     void            DoReload( void );
  212.     void            ToFromList( intn listType, ED_ListType elementType );
  213.     void            NoteEditorRepagination( void );
  214.     Boolean            CanUseCharFormatting();
  215.  
  216.     Boolean            IsMouseInSelection( SPoint32 pt, CL_Layer *curLayer, Rect& selectRect );
  217.     Boolean            mDoContinueSelection;
  218.  
  219.     HTMLInlineTSMProxy*        mProxy;
  220.     HoldUpdatesProxy*         mHoldUpdates;
  221.  
  222.     // more caret blinking and related stuff
  223.     Boolean            mCaretDrawn, mCaretActive;
  224.     Boolean            mHideCaret;
  225.     Boolean            mDisplayParagraphMarks;
  226.  
  227.     Point            mOldPoint;    // Last place cursor was adjusted. No initializing
  228.     long            mOldLastElementOver;    // id of the last element the cursor was over
  229.  
  230.     unsigned long    mLastBlink;
  231.     int32            mCaretX;
  232.     int32            mCaretYLow;
  233.     int32            mCaretYHigh;
  234.     
  235.     Boolean            mUseCharFormattingCache;
  236.     Boolean            mIsCharFormatting;
  237.     
  238.     // these are only to be used during drag of data in composer
  239.     char            *mDragData;    // warning this really isn't a "char" but void* data!!!
  240.     int32            mDragDataLength;
  241. };    // class CEditView
  242.  
  243.  
  244. //======================================
  245. class CMailEditView : public CEditView
  246. //======================================
  247. {
  248. public:
  249.     enum { pane_ID = 'html', class_ID = 'MEdp' };
  250.     
  251.     // ÑÑ Constructors
  252.  
  253.                     CMailEditView(LStream * inStream);
  254.     virtual void    InstallBackgroundColor();
  255.     virtual void    GetDefaultBackgroundColor(LO_Color* outColor) const;
  256.     virtual void    InitMailCompose();
  257.             void    SetComposeSession( CComposeSession *c ) { mComposeSession = c; };
  258.             void    SetInitialText( const char *textp );
  259.             void    InsertMessageCompositionText( const char* text,
  260.                      XP_Bool leaveCursorBeginning, XP_Bool isHTML );
  261.             void    DisplayDefaultTextBody();
  262.  
  263. private:
  264.     Int32            mStartQuoteOffset;
  265.     Int32            mEndQuoteOffset;
  266.     Boolean            mHasAutoQuoted;
  267.     Boolean            mHasInsertSignature;
  268.     Boolean            mCursorSet;
  269.     char            *mInitialText; // Draft text
  270.     CComposeSession *mComposeSession;
  271. }; // class CMailEditView
  272.  
  273.