2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-02-11 23:49:08 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-02-11 23:49:08 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-02-11 23:49:08 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-11 23:49:08 +00:00
|
|
|
|
1999-09-17 23:12:17 +00:00
|
|
|
#ifndef nsICaret_h__
|
|
|
|
#define nsICaret_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
1999-09-14 23:41:19 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsCoord.h"
|
1999-02-11 23:49:08 +00:00
|
|
|
|
2003-02-27 23:09:51 +00:00
|
|
|
struct nsRect;
|
|
|
|
struct nsPoint;
|
|
|
|
|
1999-09-17 23:12:17 +00:00
|
|
|
class nsIRenderingContext;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIView;
|
2001-07-16 02:40:48 +00:00
|
|
|
class nsIPresShell;
|
|
|
|
class nsISelection;
|
2003-02-27 23:09:51 +00:00
|
|
|
class nsIDOMNode;
|
1999-09-17 23:12:17 +00:00
|
|
|
|
1999-02-11 23:49:08 +00:00
|
|
|
// IID for the nsICaret interface
|
2005-08-11 03:44:16 +00:00
|
|
|
// c2ba7b60-ccbf-4f2b-8bf7-07493bbf3377
|
|
|
|
#define NS_ICARET_IID \
|
|
|
|
{ 0xc2ba7b60, 0xccbf, 0x4f2b, \
|
|
|
|
{ 0x8b, 0xf7, 0x07, 0x49, 0x3b, 0xbf, 0x33, 0x77 } }
|
1999-02-11 23:49:08 +00:00
|
|
|
|
|
|
|
class nsICaret: public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
2002-06-26 03:38:55 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICARET_IID)
|
1999-02-11 23:49:08 +00:00
|
|
|
|
2003-02-27 23:09:51 +00:00
|
|
|
enum EViewCoordinates {
|
2001-02-05 15:42:58 +00:00
|
|
|
eTopLevelWindowCoordinates,
|
|
|
|
eRenderingViewCoordinates,
|
2001-04-19 22:46:29 +00:00
|
|
|
eClosestViewCoordinates,
|
|
|
|
eIMECoordinates
|
2003-02-27 23:09:51 +00:00
|
|
|
};
|
2001-02-05 15:42:58 +00:00
|
|
|
|
1999-07-14 22:18:29 +00:00
|
|
|
NS_IMETHOD Init(nsIPresShell *inPresShell) = 0;
|
2003-02-27 23:09:51 +00:00
|
|
|
NS_IMETHOD Terminate() = 0;
|
1999-02-11 23:49:08 +00:00
|
|
|
|
2002-09-26 00:07:53 +00:00
|
|
|
NS_IMETHOD GetCaretDOMSelection(nsISelection **aDOMSel) = 0;
|
2000-09-14 11:45:01 +00:00
|
|
|
NS_IMETHOD SetCaretDOMSelection(nsISelection *aDOMSel) = 0;
|
2000-06-01 02:37:40 +00:00
|
|
|
|
1999-02-11 23:49:08 +00:00
|
|
|
/** SetCaretVisible will set the visibility of the caret
|
|
|
|
* @param inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it
|
|
|
|
*/
|
2000-06-01 02:37:40 +00:00
|
|
|
NS_IMETHOD SetCaretVisible(PRBool inMakeVisible) = 0;
|
|
|
|
|
|
|
|
/** GetCaretVisible will get the visibility of the caret
|
|
|
|
* @param inMakeVisible PR_TRUE it is shown, PR_FALSE it is hidden
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetCaretVisible(PRBool *outMakeVisible) = 0;
|
1999-02-11 23:49:08 +00:00
|
|
|
|
|
|
|
/** SetCaretReadOnly set the appearance of the caret
|
|
|
|
* @param inMakeReadonly PR_TRUE to show the caret in a 'read only' state,
|
|
|
|
* PR_FALSE to show the caret in normal, editing state
|
|
|
|
*/
|
2000-06-01 02:37:40 +00:00
|
|
|
NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly) = 0;
|
1999-02-13 04:47:45 +00:00
|
|
|
|
2001-02-05 15:42:58 +00:00
|
|
|
/** GetCaretCoordinates
|
|
|
|
* Get the position of the caret in coordinates relative to the typed specified (aRelativeToType).
|
1999-04-27 21:59:18 +00:00
|
|
|
* If the selection is collapsed, this returns the caret location
|
|
|
|
* and true in outIsCollapsed.
|
|
|
|
* If the selection is not collapsed, this returns the location of the focus pos,
|
|
|
|
* and false in outIsCollapsed.
|
|
|
|
*/
|
2002-08-26 20:55:30 +00:00
|
|
|
NS_IMETHOD GetCaretCoordinates(EViewCoordinates aRelativeToType, nsISelection *aDOMSel, nsRect *outCoordinates, PRBool *outIsCollapsed, nsIView **outView) = 0;
|
1999-04-01 23:57:35 +00:00
|
|
|
|
2000-06-09 04:21:02 +00:00
|
|
|
/** Erase Caret
|
|
|
|
* this will erase the caret if its drawn and reset drawn status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD EraseCaret() = 0;
|
1999-04-01 23:57:35 +00:00
|
|
|
|
2002-08-10 08:15:30 +00:00
|
|
|
NS_IMETHOD SetVisibilityDuringSelection(PRBool aVisibilityDuringSelection) = 0;
|
2003-02-27 23:09:51 +00:00
|
|
|
|
|
|
|
/** DrawAtPosition
|
|
|
|
*
|
|
|
|
* Draw the caret explicitly, at the specified node and offset.
|
|
|
|
* To avoid drawing glitches, you should call EraseCaret()
|
|
|
|
* after each call to DrawAtPosition().
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
NS_IMETHOD DrawAtPosition(nsIDOMNode* aNode, PRInt32 aOffset) = 0;
|
|
|
|
|
1999-02-11 23:49:08 +00:00
|
|
|
};
|
|
|
|
|
2003-03-05 15:08:41 +00:00
|
|
|
nsresult
|
|
|
|
NS_NewCaret(nsICaret** aInstancePtrResult);
|
1999-02-11 23:49:08 +00:00
|
|
|
|
1999-09-14 23:41:19 +00:00
|
|
|
|
|
|
|
// handy stack-based class for temporarily disabling the caret
|
|
|
|
|
|
|
|
class StCaretHider
|
|
|
|
{
|
|
|
|
public:
|
2000-06-01 02:37:40 +00:00
|
|
|
StCaretHider(nsICaret* aSelCon)
|
|
|
|
: mWasVisible(PR_FALSE), mCaret(aSelCon)
|
1999-09-14 23:41:19 +00:00
|
|
|
{
|
2000-06-01 02:37:40 +00:00
|
|
|
if (mCaret)
|
1999-09-14 23:41:19 +00:00
|
|
|
{
|
2000-06-01 02:37:40 +00:00
|
|
|
mCaret->GetCaretVisible(&mWasVisible);
|
1999-09-14 23:41:19 +00:00
|
|
|
if (mWasVisible)
|
2000-06-01 02:37:40 +00:00
|
|
|
mCaret->SetCaretVisible(PR_FALSE);
|
1999-09-14 23:41:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~StCaretHider()
|
|
|
|
{
|
2000-06-01 02:37:40 +00:00
|
|
|
if (mCaret && mWasVisible)
|
|
|
|
mCaret->SetCaretVisible(PR_TRUE);
|
1999-09-14 23:41:19 +00:00
|
|
|
// nsCOMPtr releases mPresShell
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
PRBool mWasVisible;
|
2000-06-01 02:37:40 +00:00
|
|
|
nsCOMPtr<nsICaret> mCaret;
|
1999-09-14 23:41:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-09-17 23:12:17 +00:00
|
|
|
#endif // nsICaret_h__
|
|
|
|
|