Back to index

lightning-sunbird  0.9+nobinonly
nsIFrameSelection.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00040  * NOTE!!  This is not a general class, but specific to layout and frames.
00041  * Consumers looking for the general selection interface should look at
00042  * nsISelection.
00043  */
00044 
00045 #ifndef nsIFrameSelection_h___
00046 #define nsIFrameSelection_h___
00047 
00048 #include "nsISupports.h"
00049 #include "nsIFrame.h"
00050 #include "nsISelection.h"
00051 #include "nsIContent.h"
00052 #include "nsCOMPtr.h"
00053 #include "nsISelectionController.h"
00054 
00055 class nsIPresShell;
00056 
00057 // IID for the nsIFrameSelection interface
00058 #define NS_IFRAMESELECTION_IID      \
00059 { 0x18477ed4, 0x01ff, 0x4319, \
00060   { 0x95, 0xc0, 0x63, 0x9e, 0xe4, 0x33, 0xbe, 0x92 } }
00061 
00062 
00063 //----------------------------------------------------------------------
00064 
00065 // Selection interface
00066 
00067 struct SelectionDetails
00068 {
00069   PRInt32 mStart;
00070   PRInt32 mEnd;
00071   SelectionType mType;
00072   SelectionDetails *mNext;
00073 };
00074 
00075 /*PeekOffsetStruct
00076    *  @param mShell is used to get the PresContext usefull for measuring text ect.
00077    *  @param mDesiredX is the "desired" location of the new caret
00078    *  @param mAmount eWord, eCharacter, eLine
00079    *  @param mDirection enum defined in this file to be eForward or eBackward
00080    *  @param mStartOffset start offset to start the peek. 0 == beginning -1 = end
00081    *  @param mResultContent content that actually is the next/previous
00082    *  @param mResultOffset offset for result content
00083    *  @param mResultFrame resulting frame for peeking
00084    *  @param mEatingWS boolean to tell us the state of our search for Next/Prev
00085    *  @param mPreferLeft true = prev line end, false = next line begin
00086    *  @param mJumpLines if this is true then its ok to cross lines while peeking
00087    *  @param mScrollViewStop if this is true then stop peeking across scroll view boundary
00088 */
00089 struct nsPeekOffsetStruct
00090 {
00091   void SetData(nsIPresShell *aShell,
00092                nscoord aDesiredX, 
00093                nsSelectionAmount aAmount,
00094                nsDirection aDirection,
00095                PRInt32 aStartOffset, 
00096                PRBool aEatingWS,
00097                PRBool aPreferLeft,
00098                PRBool aJumpLines,
00099                PRBool aScrollViewStop,
00100                PRBool aIsKeyboardSelect)
00101       {
00102        mShell=aShell;
00103        mDesiredX=aDesiredX;
00104        mAmount=aAmount;
00105        mDirection=aDirection;
00106        mStartOffset=aStartOffset;
00107        mEatingWS=aEatingWS;
00108        mPreferLeft=aPreferLeft;
00109        mJumpLines = aJumpLines;
00110        mScrollViewStop = aScrollViewStop;
00111        mIsKeyboardSelect = aIsKeyboardSelect;
00112       }
00113   nsIPresShell *mShell;
00114   nscoord mDesiredX;
00115   nsSelectionAmount mAmount;
00116   nsDirection mDirection;
00117   PRInt32 mStartOffset;
00118   nsCOMPtr<nsIContent> mResultContent;
00119   PRInt32 mContentOffset;
00120   PRInt32 mContentOffsetEnd;
00121   nsIFrame *mResultFrame;
00122   PRBool mEatingWS;
00123   PRBool mPreferLeft;
00124   PRBool mJumpLines;
00125   PRBool mScrollViewStop;
00126   PRBool mIsKeyboardSelect;
00127 };
00128 
00129 class nsIScrollableView;
00130 
00131 
00132 class nsIFrameSelection : public nsISupports {
00133 public:
00134   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMESELECTION_IID)
00135   enum HINT { HINTLEFT = 0, HINTRIGHT = 1};  //end of this line or beginning of next
00136 
00142   NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter) = 0; //default since this isnt used for embedding
00143 
00144   /* SetScrollableView sets the scroll view
00145    *  @param aScrollView is the scroll view for this selection.
00146    */
00147   NS_IMETHOD SetScrollableView(nsIScrollableView *aScrollView) =0;
00148 
00149   /* GetScrollableView gets the current scroll view
00150    *  @param aScrollView is the scroll view for this selection.
00151    */
00152   NS_IMETHOD GetScrollableView(nsIScrollableView **aScrollView) =0;
00153 
00158   NS_IMETHOD ShutDown() = 0;
00159 
00165   NS_IMETHOD HandleTextEvent(nsGUIEvent *aGuiEvent) = 0;
00166 
00172   NS_IMETHOD HandleKeyEvent(nsPresContext* aPresContext, nsGUIEvent *aGuiEvent) = 0;
00173 
00187   NS_IMETHOD HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset , 
00188                        PRBool aContinueSelection, PRBool aMultipleSelection, PRBool aHint) = 0; 
00189 
00195   NS_IMETHOD HandleDrag(nsPresContext *aPresContext, nsIFrame *aFrame, nsPoint& aPoint) = 0;
00196 
00209   NS_IMETHOD HandleTableSelection(nsIContent *aParentContent, PRInt32 aContentOffset, PRInt32 aTarget, nsMouseEvent *aMouseEvent) = 0;
00210 
00220   NS_IMETHOD StartAutoScrollTimer(nsPresContext *aPresContext, nsIView* aFrame, nsPoint& aPoint, PRUint32 aDelay) = 0;
00221 
00224   NS_IMETHOD StopAutoScrollTimer() = 0;
00225 
00230   NS_IMETHOD EnableFrameNotification(PRBool aEnable) = 0;
00231 
00240   NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,
00241                              SelectionDetails **aReturnDetails, PRBool aSlowCheck) = 0;
00242 
00247   NS_IMETHOD SetMouseDownState(PRBool aState)=0;
00248 
00253   NS_IMETHOD GetMouseDownState(PRBool *aState)=0;
00254 
00258   NS_IMETHOD GetTableCellSelection(PRBool *aState)=0;
00259 
00264   NS_IMETHOD GetSelection(SelectionType aSelectionType, nsISelection **aSelection)=0;
00265 
00275   NS_IMETHOD ScrollSelectionIntoView(SelectionType aSelectionType, SelectionRegion aRegion, PRBool aIsSynchronous)=0;
00276 
00281   NS_IMETHOD RepaintSelection(nsPresContext* aPresContext, SelectionType aSelectionType)=0;
00282 
00290   NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset)=0;
00291 
00300   NS_IMETHOD AdjustOffsetsFromStyle(nsIFrame *aFrame, PRBool *changeSelection,
00301         nsIContent** outContent, PRInt32* outStartOffset, PRInt32* outEndOffset)=0;
00302   
00303   
00304   NS_IMETHOD GetHint(HINT *aHint)=0;
00305   NS_IMETHOD SetHint(HINT aHint)=0;
00306 
00312   NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend)=0;
00313 
00319   NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend)=0;
00320 
00326   NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend)=0;
00327 
00333   NS_IMETHOD IntraLineMove(PRBool aForward, PRBool aExtend)=0;
00334 
00353   NS_IMETHOD CommonPageMove(PRBool aForward, 
00354                             PRBool aExtend, 
00355                             nsIScrollableView *aScrollableView, 
00356                             nsIFrameSelection *aFrameSel)=0;
00357 
00361   NS_IMETHOD SelectAll()=0;
00362 
00365   NS_IMETHOD SetDisplaySelection(PRInt16 aState)=0;
00366   NS_IMETHOD GetDisplaySelection(PRInt16 *aState)=0;
00367 
00379   NS_IMETHOD SetDelayCaretOverExistingSelection(PRBool aDelay)=0;
00380 
00388   NS_IMETHOD GetDelayCaretOverExistingSelection(PRBool *aDelay)=0;
00389 
00398   NS_IMETHOD SetDelayedCaretData(nsMouseEvent *aMouseEvent)=0;
00399 
00406   NS_IMETHOD GetDelayedCaretData(nsMouseEvent **aMouseEvent)=0;
00407 
00408 
00414   NS_IMETHOD GetLimiter(nsIContent **aLimiterContent)=0;
00415 
00420   NS_IMETHOD SetMouseDoubleDown(PRBool aDoubleDown)=0;
00421 
00425   NS_IMETHOD GetMouseDoubleDown(PRBool *aDoubleDown)=0;
00426 
00433   NS_IMETHOD MaintainSelection()=0;
00434 
00435 #ifdef IBMBIDI
00436 
00449   NS_IMETHOD GetPrevNextBidiLevels(nsPresContext *aPresContext, nsIContent *aNode, PRUint32 aContentOffset,
00450                                    nsIFrame **aPrevFrame, nsIFrame **aNextFrame, PRUint8 *aPrevLevel, PRUint8 *aNextLevel)=0;
00451 
00461   NS_IMETHOD GetFrameFromLevel(nsPresContext *aPresContext, nsIFrame *aFrameIn, nsDirection aDirection, PRUint8 aBidiLevel,
00462                                nsIFrame **aFrameOut)=0;
00463 
00464 #endif // IBMBIDI
00465 };
00466 
00467 
00468 
00469 #endif /* nsIFrameSelection_h___ */