1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03: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.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
#ifndef nsIPresContext_h___
|
|
|
|
#define nsIPresContext_h___
|
|
|
|
|
|
|
|
#include "nslayout.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsRect.h"
|
1998-07-16 08:34:59 +04:00
|
|
|
#include "nsColor.h"
|
1998-09-26 22:36:59 +04:00
|
|
|
#include "nsIFrameImageLoader.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-12 02:57:05 +04:00
|
|
|
struct nsFont;
|
|
|
|
|
|
|
|
class nsIContent;
|
1998-09-10 23:32:14 +04:00
|
|
|
class nsIDocument;
|
1998-05-12 02:57:05 +04:00
|
|
|
class nsIDeviceContext;
|
|
|
|
class nsIFontMetrics;
|
|
|
|
class nsIFrame;
|
1999-04-14 01:48:49 +04:00
|
|
|
class nsIImage;
|
1998-05-12 02:57:05 +04:00
|
|
|
class nsIImageGroup;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsILinkHandler;
|
|
|
|
class nsIPresShell;
|
1998-07-31 09:54:59 +04:00
|
|
|
class nsIPref;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsIStyleContext;
|
1998-05-19 01:03:10 +04:00
|
|
|
class nsIAtom;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsString;
|
1998-06-24 01:53:02 +04:00
|
|
|
class nsIEventStateManager;
|
1999-06-23 07:29:44 +04:00
|
|
|
class nsIURI;
|
1999-09-10 09:51:08 +04:00
|
|
|
class nsILookAndFeel;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#define NS_IPRESCONTEXT_IID \
|
|
|
|
{ 0x0a5d12e0, 0x944e, 0x11d1, \
|
|
|
|
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
enum nsCompatibility {
|
|
|
|
eCompatibility_Standard = 1,
|
|
|
|
eCompatibility_NavQuirks = 2
|
|
|
|
};
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-03-03 01:43:26 +03:00
|
|
|
enum nsWidgetRendering {
|
|
|
|
eWidgetRendering_Native = 1,
|
1999-07-21 02:32:41 +04:00
|
|
|
eWidgetRendering_Gfx = 2,
|
|
|
|
eWidgetRendering_PartialGfx = 3
|
1999-03-03 01:43:26 +03:00
|
|
|
};
|
|
|
|
|
1999-08-06 09:11:39 +04:00
|
|
|
enum nsWidgetType {
|
|
|
|
eWidgetType_Button = 1,
|
|
|
|
eWidgetType_Checkbox = 2,
|
|
|
|
eWidgetType_Radio = 3,
|
|
|
|
eWidgetType_Text = 4
|
|
|
|
};
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// An interface for presentation contexts. Presentation contexts are
|
|
|
|
// objects that provide an outer context for a presentation shell.
|
|
|
|
class nsIPresContext : public nsISupports {
|
|
|
|
public:
|
1999-04-30 12:59:11 +04:00
|
|
|
static const nsIID& GetIID() { static nsIID iid = NS_IPRESCONTEXT_IID; return iid; }
|
|
|
|
|
1998-06-25 08:24:45 +04:00
|
|
|
/**
|
|
|
|
* Initialize the presentation context from a particular device.
|
|
|
|
*/
|
1998-11-26 21:08:44 +03:00
|
|
|
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop the presentation in preperation for destruction.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD Stop(void) = 0;
|
1998-06-25 08:24:45 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* Set the presentation shell that this context is bound to.
|
|
|
|
* A presentation context may only be bound to a single shell.
|
|
|
|
*/
|
1998-11-26 21:08:44 +03:00
|
|
|
NS_IMETHOD SetShell(nsIPresShell* aShell) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the PresentationShell that this context is bound to.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetShell(nsIPresShell** aResult) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
/**
|
|
|
|
* Get a reference to the prefs API for this context
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetPrefs(nsIPref** aPrefsResult) = 0;
|
1998-07-31 09:54:59 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Access compatibility mode for this context
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult) = 0;
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode) = 0;
|
|
|
|
|
1999-03-03 01:43:26 +03:00
|
|
|
/**
|
|
|
|
* Access the widget rendering mode for this context
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0;
|
|
|
|
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0;
|
|
|
|
|
1999-09-10 09:51:08 +04:00
|
|
|
/**
|
|
|
|
* Get look and feel object
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel) = 0;
|
|
|
|
|
1998-09-05 07:51:16 +04:00
|
|
|
/**
|
|
|
|
* Get base url for presentation
|
|
|
|
*/
|
1999-06-23 07:29:44 +04:00
|
|
|
NS_IMETHOD GetBaseURL(nsIURI** aURLResult) = 0;
|
1998-09-05 07:51:16 +04:00
|
|
|
|
1998-12-02 03:28:57 +03:00
|
|
|
/**
|
|
|
|
* Get medium of presentation
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0;
|
1998-12-02 03:28:57 +03:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* Resolve style for the given piece of content that will be a child
|
1998-11-03 23:16:23 +03:00
|
|
|
* of the aParentContext. Don't use this for pseudo frames.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-02-11 18:53:26 +03:00
|
|
|
NS_IMETHOD ResolveStyleContextFor(nsIContent* aContent,
|
|
|
|
nsIStyleContext* aParentContext,
|
1999-02-12 20:45:58 +03:00
|
|
|
PRBool aForceUnique,
|
|
|
|
nsIStyleContext** aResult) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-19 01:03:10 +04:00
|
|
|
/**
|
1998-11-03 23:16:23 +03:00
|
|
|
* Resolve style for a pseudo frame within the given aParentContent & aParentContext.
|
1999-02-12 09:19:07 +03:00
|
|
|
* The tag should be lowercase and inclue the colon.
|
|
|
|
* ie: NS_NewAtom(":first-line");
|
1998-05-19 01:03:10 +04:00
|
|
|
*/
|
1999-02-11 18:53:26 +03:00
|
|
|
NS_IMETHOD ResolvePseudoStyleContextFor(nsIContent* aParentContent,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsIStyleContext* aParentContext,
|
1999-02-12 20:45:58 +03:00
|
|
|
PRBool aForceUnique,
|
|
|
|
nsIStyleContext** aResult) = 0;
|
1998-05-19 01:03:10 +04:00
|
|
|
|
|
|
|
/**
|
1998-11-03 23:16:23 +03:00
|
|
|
* Probe style for a pseudo frame within the given aParentContent & aParentContext.
|
1998-05-19 01:03:10 +04:00
|
|
|
* This will return nsnull id there are no explicit rules for the pseudo element.
|
1999-02-12 09:19:07 +03:00
|
|
|
* The tag should be lowercase and inclue the colon.
|
|
|
|
* ie: NS_NewAtom(":first-line");
|
1998-05-19 01:03:10 +04:00
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD ProbePseudoStyleContextFor(nsIContent* aParentContent,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsIStyleContext* aParentContext,
|
|
|
|
PRBool aForceUnique,
|
|
|
|
nsIStyleContext** aResult) = 0;
|
1998-07-31 09:54:59 +04:00
|
|
|
|
1999-09-04 03:35:41 +04:00
|
|
|
/**
|
|
|
|
* For a given frame tree, get a new style context that is the equivalent
|
|
|
|
* but within a new parent
|
|
|
|
*/
|
|
|
|
NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame,
|
|
|
|
nsIStyleContext* aNewParentContext) = 0;
|
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* Get the font metrics for a given font.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-06-13 02:31:57 +04:00
|
|
|
/** Get the default font */
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetDefaultFont(nsFont& aResult) = 0;
|
1999-06-13 02:31:57 +04:00
|
|
|
/** Set the default font */
|
|
|
|
NS_IMETHOD SetDefaultFont(nsFont& aFont) = 0;
|
1999-02-12 20:45:58 +03:00
|
|
|
virtual const nsFont& GetDefaultFontDeprecated() = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-06-13 02:31:57 +04:00
|
|
|
/** Get the default fixed pitch font */
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetDefaultFixedFont(nsFont& aResult) = 0;
|
1999-06-13 02:31:57 +04:00
|
|
|
/** Set the default fixed pitch font */
|
|
|
|
NS_IMETHOD SetDefaultFixedFont(nsFont& aFont) = 0;
|
1999-02-12 20:45:58 +03:00
|
|
|
virtual const nsFont& GetDefaultFixedFontDeprecated() = 0;
|
1998-07-17 09:41:41 +04:00
|
|
|
|
1998-07-25 05:11:49 +04:00
|
|
|
/**
|
|
|
|
* Access Nav's magic font scaler value
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetFontScaler(PRInt32* aResult) = 0;
|
1998-11-26 21:08:44 +03:00
|
|
|
NS_IMETHOD SetFontScaler(PRInt32 aScaler) = 0;
|
1998-07-25 05:11:49 +04:00
|
|
|
|
1998-07-17 09:41:41 +04:00
|
|
|
/**
|
|
|
|
* Get the defualt colors
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetDefaultColor(nscolor* aColor) = 0;
|
|
|
|
NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor) = 0;
|
1999-06-13 02:31:57 +04:00
|
|
|
NS_IMETHOD GetDefaultBackgroundImage(nsString& aImage) = 0;
|
|
|
|
NS_IMETHOD GetDefaultBackgroundImageRepeat(PRUint8* aRepeat) = 0;
|
|
|
|
NS_IMETHOD GetDefaultBackgroundImageOffset(nscoord* aX, nscoord* aY) = 0;
|
|
|
|
NS_IMETHOD GetDefaultBackgroundImageAttachment(PRUint8* aRepeat) = 0;
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD SetDefaultColor(nscolor aColor) = 0;
|
|
|
|
NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor) = 0;
|
1999-06-13 02:31:57 +04:00
|
|
|
NS_IMETHOD SetDefaultBackgroundImage(const nsString& aImage) = 0;
|
|
|
|
NS_IMETHOD SetDefaultBackgroundImageRepeat(PRUint8 aRepeat) = 0;
|
|
|
|
NS_IMETHOD SetDefaultBackgroundImageOffset(nscoord aX, nscoord aY) = 0;
|
|
|
|
NS_IMETHOD SetDefaultBackgroundImageAttachment(PRUint8 aRepeat) = 0;
|
1998-07-17 09:41:41 +04:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetImageGroup(nsIImageGroup** aGroupResult) = 0;
|
1998-05-12 02:57:05 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
1998-05-12 02:57:05 +04:00
|
|
|
* Load an image for the target frame. This call can be made
|
1998-07-16 08:34:59 +04:00
|
|
|
* repeated with only a single image ever being loaded. If
|
|
|
|
* aNeedSizeUpdate is PR_TRUE, then when the image's size is
|
1998-05-12 02:57:05 +04:00
|
|
|
* determined the target frame will be reflowed (via a
|
|
|
|
* ContentChanged notification on the presentation shell). When the
|
1998-07-16 08:34:59 +04:00
|
|
|
* image's data is ready for rendering the target frame's Paint()
|
|
|
|
* method will be invoked (via the ViewManager) so that the
|
|
|
|
* appropriate damage repair is done.
|
|
|
|
*
|
|
|
|
* @param aBackgroundColor - If the background color is NULL, a mask
|
|
|
|
* will be generated for transparent images. If the background
|
|
|
|
* color is non-NULL, it indicates the RGB value to be folded
|
|
|
|
* into the transparent areas of the image and no mask is created.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1998-07-31 09:54:59 +04:00
|
|
|
NS_IMETHOD StartLoadImage(const nsString& aURL,
|
|
|
|
const nscolor* aBackgroundColor,
|
1999-04-14 01:48:49 +04:00
|
|
|
const nsSize* aDesiredSize,
|
1998-07-31 09:54:59 +04:00
|
|
|
nsIFrame* aTargetFrame,
|
1999-04-14 01:48:49 +04:00
|
|
|
nsIFrameImageLoaderCB aCallBack,
|
|
|
|
void* aClosure,
|
|
|
|
nsIFrameImageLoader** aResult) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop a specific image load being done on behalf of the argument frame.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD StopLoadImage(nsIFrame* aForFrame,
|
|
|
|
nsIFrameImageLoader* aLoader) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop any image loading being done on behalf of the argument frame.
|
|
|
|
*/
|
1999-04-14 01:48:49 +04:00
|
|
|
NS_IMETHOD StopAllLoadImagesFor(nsIFrame* aForFrame) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
NS_IMETHOD SetContainer(nsISupports* aContainer) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD GetContainer(nsISupports** aResult) = 0;
|
|
|
|
|
1998-07-13 23:49:07 +04:00
|
|
|
// XXX this are going to be replaced with set/get container
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IMETHOD SetLinkHandler(nsILinkHandler* aHandler) = 0;
|
|
|
|
NS_IMETHOD GetLinkHandler(nsILinkHandler** aResult) = 0;
|
|
|
|
|
|
|
|
/**
|
1998-07-13 23:49:07 +04:00
|
|
|
* Get the visible area associated with this presentation context.
|
|
|
|
* This is the size of the visiable area that is used for
|
|
|
|
* presenting the document. The returned value is in the standard
|
|
|
|
* nscoord units (as scaled by the device context).
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1998-11-26 21:08:44 +03:00
|
|
|
NS_IMETHOD GetVisibleArea(nsRect& aResult) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
1998-07-13 23:49:07 +04:00
|
|
|
* Set the currently visible area. The units for r are standard
|
|
|
|
* nscoord units (as scaled by the device context).
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1998-11-26 21:08:44 +03:00
|
|
|
NS_IMETHOD SetVisibleArea(const nsRect& r) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if this presentation context is a paginated
|
|
|
|
* context.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD IsPaginated(PRBool* aResult) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the page width if this is a paginated context.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetPageWidth(nscoord* aResult) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the page height if this is a paginated context
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetPageHeight(nscoord* aResult) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD GetPixelsToTwips(float* aResult) const = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetTwipsToPixels(float* aResult) const = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-11-14 04:52:27 +03:00
|
|
|
//XXX this is probably not an ideal name. MMP
|
|
|
|
/**
|
|
|
|
* Do pixels to twips conversion taking into account
|
|
|
|
* differing size of a "pixel" from device to device.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
|
1998-11-14 04:52:27 +03:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
//be sure to Relase() after you are done with the Get()
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const = 0;
|
1998-06-24 01:53:02 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
1998-07-31 09:54:59 +04:00
|
|
|
// Bit values for StartLoadImage's aImageStatus
|
1998-05-09 07:21:19 +04:00
|
|
|
#define NS_LOAD_IMAGE_STATUS_ERROR 0x1
|
|
|
|
#define NS_LOAD_IMAGE_STATUS_SIZE 0x2
|
|
|
|
#define NS_LOAD_IMAGE_STATUS_BITS 0x4
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Factory method to create a "galley" presentation context (galley is
|
|
|
|
// a kind of view that has no limit to the size of a page)
|
|
|
|
extern NS_LAYOUT nsresult
|
|
|
|
NS_NewGalleyContext(nsIPresContext** aInstancePtrResult);
|
|
|
|
|
|
|
|
// Factory method to create a "paginated" presentation context for
|
|
|
|
// the screen.
|
|
|
|
extern NS_LAYOUT nsresult
|
|
|
|
NS_NewPrintPreviewContext(nsIPresContext** aInstancePtrResult);
|
|
|
|
|
1998-12-02 06:21:55 +03:00
|
|
|
// Factory method to create a "paginated" presentation context for
|
|
|
|
// printing
|
|
|
|
extern NS_LAYOUT nsresult
|
|
|
|
NS_NewPrintContext(nsIPresContext** aInstancePtrResult);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif /* nsIPresContext_h___ */
|