2001-09-26 00:16:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +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/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +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.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 00:16:04 +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:43:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* Contributor(s):
|
2001-09-21 13:52:39 +00:00
|
|
|
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
2001-09-26 00:16:04 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +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-26 00:16:04 +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-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 00:16:04 +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-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 00:16:04 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#ifndef nsIDeviceContext_h___
|
|
|
|
#define nsIDeviceContext_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsRect.h"
|
1998-06-25 04:24:45 +00:00
|
|
|
#include "nsIWidget.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIRenderingContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
class nsIView;
|
|
|
|
class nsIFontMetrics;
|
|
|
|
class nsIWidget;
|
1998-11-14 02:05:13 +00:00
|
|
|
class nsIDeviceContextSpec;
|
1999-12-07 23:27:17 +00:00
|
|
|
class nsIAtom;
|
1999-01-21 23:55:27 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
struct nsFont;
|
1999-01-21 23:55:27 +00:00
|
|
|
struct nsColor;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
//a cross platform way of specifying a native device context
|
1998-06-11 21:26:21 +00:00
|
|
|
typedef void * nsNativeDeviceContext;
|
|
|
|
|
2001-09-21 13:52:39 +00:00
|
|
|
/* error codes for printer device contexts */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_BASE (1) /* adjustable :-) */
|
|
|
|
/* Unix: print command (lp/lpr) not found */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_CMD_NOT_FOUND \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+1)
|
|
|
|
/* Unix: print command returned an error */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_CMD_FAILURE \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+2)
|
|
|
|
/* no printer available (e.g. cannot find _any_ printer) */
|
2002-01-01 12:58:53 +00:00
|
|
|
#define NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE \
|
2001-09-21 13:52:39 +00:00
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+3)
|
|
|
|
/* _specified_ (by name) printer not found */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_NAME_NOT_FOUND \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+4)
|
|
|
|
/* access to printer denied */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_ACCESS_DENIED \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+5)
|
|
|
|
/* invalid printer attribute (for example: unsupported paper size etc.) */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_INVALID_ATTRIBUTE \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+6)
|
|
|
|
/* printer not "ready" (offline ?) */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_PRINTER_NOT_READY \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+8)
|
|
|
|
/* printer out of paper */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_OUT_OF_PAPER \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+9)
|
|
|
|
/* generic printer I/O error */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_PRINTER_IO_ERROR \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+10)
|
|
|
|
/* print-to-file: could not open output file */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+11)
|
|
|
|
/* print-to-file: I/O error while printing to file */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_FILE_IO_ERROR \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+12)
|
2002-01-01 12:58:53 +00:00
|
|
|
/* print preview: needs at least one printer */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_PRINTPREVIEW \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+13)
|
2002-01-08 01:15:25 +00:00
|
|
|
/* print: starting document */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_STARTDOC \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+14)
|
|
|
|
/* print: ending document */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_ENDDOC \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+15)
|
|
|
|
/* print: starting page */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_STARTPAGE \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+16)
|
|
|
|
/* print: ending page */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_ENDPAGE \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+17)
|
2002-01-12 12:58:46 +00:00
|
|
|
/* print: print while in print preview */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+18)
|
2002-01-29 03:03:56 +00:00
|
|
|
/* requested page size not supported by printer */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_PAPER_SIZE_NOT_SUPPORTED \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+19)
|
|
|
|
/* requested page orientation not supported */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_ORIENTATION_NOT_SUPPORTED \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+20)
|
|
|
|
/* requested colorspace not supported (like printing "color" on a "grayscale"-only printer) */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_COLORSPACE_NOT_SUPPORTED \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+21)
|
|
|
|
/* too many copies requested */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_TOO_MANY_COPIES \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+22)
|
2002-02-23 15:32:03 +00:00
|
|
|
/* driver configuration error */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_DRIVER_CONFIGURATION_ERROR \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+23)
|
|
|
|
/* Xprint module specific: Xprt server broken */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+24)
|
2002-03-23 16:48:58 +00:00
|
|
|
/* The document is still being loaded, can't Print Preview */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+25)
|
|
|
|
/* The document was asked to be destroyed while we were preparing printing */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+26)
|
2002-04-11 00:45:11 +00:00
|
|
|
/* Cannot Print or Print Preview XUL Documents */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_NO_XUL \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+27)
|
2002-05-07 12:03:37 +00:00
|
|
|
/* The toolkit no longer supports the Print Dialog (for embedders) */
|
|
|
|
#define NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+28)
|
|
|
|
/* The was wasn't any Print Prompt service registered (this shouldn't happen) */
|
|
|
|
#define NS_ERROR_GFX_NO_PRINTROMPTSERVICE \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+29)
|
2003-04-17 20:17:01 +00:00
|
|
|
/* Xprint module specific: No Xprint servers found */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+30)
|
2003-08-01 01:56:15 +00:00
|
|
|
/* requested plex mode not supported by printer */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+31)
|
2004-02-19 21:58:40 +00:00
|
|
|
/* The document is still being loaded */
|
|
|
|
#define NS_ERROR_GFX_PRINTER_DOC_IS_BUSY \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+32)
|
|
|
|
/* Printing is not implemented */
|
|
|
|
#define NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+33)
|
|
|
|
/* Cannot load the matching print module */
|
|
|
|
#define NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE \
|
|
|
|
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+34)
|
|
|
|
|
2001-11-03 14:59:39 +00:00
|
|
|
/**
|
|
|
|
* Conts need for Print Preview
|
|
|
|
*/
|
|
|
|
#ifdef NS_PRINT_PREVIEW
|
2002-01-11 11:56:10 +00:00
|
|
|
const PRUint8 kUseAltDCFor_NONE = 0x00; // Do not use the AltDC for anything
|
|
|
|
const PRUint8 kUseAltDCFor_FONTMETRICS = 0x01; // Use it for only getting the font metrics
|
|
|
|
const PRUint8 kUseAltDCFor_CREATERC_REFLOW = 0x02; // Use when creating RenderingContexts for Reflow
|
|
|
|
const PRUint8 kUseAltDCFor_CREATERC_PAINT = 0x04; // Use when creating RenderingContexts for Painting
|
|
|
|
const PRUint8 kUseAltDCFor_SURFACE_DIM = 0x08; // Use it for getting the Surface Dimensions
|
2001-11-03 14:59:39 +00:00
|
|
|
#endif
|
2001-09-21 13:52:39 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#define NS_IDEVICE_CONTEXT_IID \
|
|
|
|
{ 0x5931c580, 0xb917, 0x11d1, \
|
|
|
|
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
|
|
|
|
1998-08-19 00:37:05 +00:00
|
|
|
//a cross platform way of specifying a native palette handle
|
|
|
|
typedef void * nsPalette;
|
|
|
|
|
2001-11-07 04:36:47 +00:00
|
|
|
//structure used to return information about a device's palette capabilities
|
|
|
|
struct nsPaletteInfo {
|
|
|
|
PRPackedBool isPaletteDevice;
|
|
|
|
PRUint16 sizePalette; // number of entries in the palette
|
|
|
|
PRUint16 numReserved; // number of reserved palette entries
|
|
|
|
nsPalette palette; // native palette handle
|
|
|
|
};
|
|
|
|
|
1999-01-21 23:55:27 +00:00
|
|
|
typedef enum {
|
2001-10-02 03:10:56 +00:00
|
|
|
eSystemFont_Caption, // css2
|
|
|
|
eSystemFont_Icon,
|
|
|
|
eSystemFont_Menu,
|
|
|
|
eSystemFont_MessageBox,
|
|
|
|
eSystemFont_SmallCaption,
|
|
|
|
eSystemFont_StatusBar,
|
|
|
|
|
|
|
|
eSystemFont_Window, // css3
|
|
|
|
eSystemFont_Document,
|
|
|
|
eSystemFont_Workspace,
|
|
|
|
eSystemFont_Desktop,
|
|
|
|
eSystemFont_Info,
|
|
|
|
eSystemFont_Dialog,
|
|
|
|
eSystemFont_Button,
|
|
|
|
eSystemFont_PullDownMenu,
|
|
|
|
eSystemFont_List,
|
|
|
|
eSystemFont_Field,
|
|
|
|
|
|
|
|
eSystemFont_Tooltips, // moz
|
2002-05-01 00:17:04 +00:00
|
|
|
eSystemFont_Widget
|
2001-10-02 03:10:56 +00:00
|
|
|
} nsSystemFontID;
|
1998-08-03 04:53:25 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
class nsIDeviceContext : public nsISupports
|
|
|
|
{
|
|
|
|
public:
|
1999-06-14 06:16:08 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_IID)
|
1998-12-18 01:33:04 +00:00
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Initialize the device context from a widget
|
|
|
|
* @param aWidget a native widget to initialize the device context from
|
|
|
|
* @return error status
|
|
|
|
*/
|
1998-08-27 05:05:03 +00:00
|
|
|
NS_IMETHOD Init(nsNativeWidget aWidget) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Create a rendering context and initialize it from an nsIView
|
|
|
|
* @param aView view to initialize context from
|
|
|
|
* @param aContext out parameter for new rendering context
|
|
|
|
* @return error status
|
|
|
|
*/
|
1998-08-27 05:05:03 +00:00
|
|
|
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) = 0;
|
1998-11-14 02:05:13 +00:00
|
|
|
|
2002-08-06 03:27:05 +00:00
|
|
|
/**
|
|
|
|
* Create a rendering context and initialize it from an nsDrawingSurface
|
|
|
|
* @param nsDrawingSurface widget to initialize context from
|
|
|
|
* @param aContext out parameter for new rendering context
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateRenderingContext(nsDrawingSurface aSurface, nsIRenderingContext *&aContext) = 0;
|
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Create a rendering context and initialize it from an nsIWidget
|
|
|
|
* @param aWidget widget to initialize context from
|
|
|
|
* @param aContext out parameter for new rendering context
|
|
|
|
* @return error status
|
|
|
|
*/
|
1998-10-02 01:07:56 +00:00
|
|
|
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) = 0;
|
1998-11-14 02:05:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a rendering context and initialize it. This API should *only* be called
|
|
|
|
* on device contexts whose SupportsNativeWidgets() method return PR_FALSE.
|
|
|
|
* @param aContext out parameter for new rendering context
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext) = 0;
|
|
|
|
|
|
|
|
/**
|
2002-08-06 03:27:05 +00:00
|
|
|
* Create an uninitalised rendering context.
|
|
|
|
* @param aContext out parameter for new rendering context
|
1998-11-14 02:05:13 +00:00
|
|
|
* @return error status
|
|
|
|
*/
|
2002-08-06 03:27:05 +00:00
|
|
|
NS_IMETHOD CreateRenderingContextInstance(nsIRenderingContext *&aContext) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Query the device to see if it supports native widgets. If not, then
|
|
|
|
* nsIWidget->Create() calls should be avoided.
|
|
|
|
* @param aSupportsWidgets out paramater. If PR_TRUE, then native widgets
|
|
|
|
* can be created.
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain the size of a device unit relative to a Twip. A twip is 1/20 of
|
|
|
|
* a point (which is 1/72 of an inch).
|
2004-02-05 01:57:10 +00:00
|
|
|
* @return conversion value
|
1998-11-14 02:05:13 +00:00
|
|
|
*/
|
2004-02-05 01:57:10 +00:00
|
|
|
float DevUnitsToTwips() const { return mPixelsToTwips; }
|
1998-11-14 02:05:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain the size of a Twip relative to a device unit.
|
2004-02-05 01:57:10 +00:00
|
|
|
* @return conversion value
|
1998-11-14 02:05:13 +00:00
|
|
|
*/
|
2004-02-05 01:57:10 +00:00
|
|
|
float TwipsToDevUnits() const { return mTwipsToPixels; }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Set the scale factor to convert units used by the application
|
|
|
|
* to device units. Typically, an application will query the device
|
|
|
|
* for twips to device units scale and then set the scale
|
|
|
|
* to convert from whatever unit the application wants to use
|
|
|
|
* to device units. From that point on, all other parts of the
|
|
|
|
* app can use the Get* methods below to figure out how
|
|
|
|
* to convert device units <-> app units.
|
|
|
|
* @param aAppUnits scale value to convert from application defined
|
|
|
|
* units to device units.
|
|
|
|
*/
|
2004-02-05 01:57:10 +00:00
|
|
|
void SetAppUnitsToDevUnits(float aAppUnits)
|
|
|
|
{
|
|
|
|
mAppUnitsToDevUnits = aAppUnits;
|
|
|
|
}
|
1998-11-14 02:05:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the scale factor to convert device units to units
|
|
|
|
* used by the application. This should generally be
|
|
|
|
* 1.0f / the value passed into SetAppUnitsToDevUnits().
|
|
|
|
* @param aDevUnits scale value to convert from device units to
|
|
|
|
* application defined units
|
|
|
|
*/
|
2004-02-05 01:57:10 +00:00
|
|
|
void SetDevUnitsToAppUnits(float aDevUnits)
|
|
|
|
{
|
|
|
|
mDevUnitsToAppUnits = aDevUnits;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Get the scale factor to convert from application defined
|
|
|
|
* units to device units.
|
2004-02-05 01:57:10 +00:00
|
|
|
* @param aAppUnits scale value
|
1998-11-14 02:05:13 +00:00
|
|
|
*/
|
2004-02-05 01:57:10 +00:00
|
|
|
float AppUnitsToDevUnits() const { return mAppUnitsToDevUnits; }
|
1998-11-14 02:05:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the scale factor to convert from device units to
|
|
|
|
* application defined units.
|
|
|
|
* @param aDevUnits out paramater for scale value
|
|
|
|
* @return error status
|
|
|
|
*/
|
2004-02-05 01:57:10 +00:00
|
|
|
float DevUnitsToAppUnits() const { return mDevUnitsToAppUnits; }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Get the value used to scale a "standard" pixel to a pixel
|
|
|
|
* of the same physical size for this device. a standard pixel
|
|
|
|
* is defined as a pixel on display 0. this is used to make
|
|
|
|
* sure that entities defined in pixel dimensions maintain a
|
|
|
|
* constant relative size when displayed from one output
|
|
|
|
* device to another.
|
|
|
|
* @param aScale out parameter for scale value
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const = 0;
|
|
|
|
|
2001-11-26 12:48:41 +00:00
|
|
|
/**
|
|
|
|
* Get the value used to scale a "standard" pixel to a pixel
|
|
|
|
* of the same physical size for this device. a standard pixel
|
|
|
|
* is defined as a pixel on display 0. this is used to make
|
|
|
|
* sure that entities defined in pixel dimensions maintain a
|
|
|
|
* constant relative size when displayed from one output
|
|
|
|
* device to another.
|
|
|
|
* @param aScale in parameter for scale value
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetCanonicalPixelScale(float aScale) = 0;
|
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Get the width of a vertical scroll bar and the height
|
|
|
|
* of a horizontal scrollbar in application units.
|
|
|
|
* @param aWidth out parameter for width
|
|
|
|
* @param aHeight out parameter for height
|
|
|
|
* @return error status
|
|
|
|
*/
|
1998-08-27 18:30:55 +00:00
|
|
|
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-01-21 23:55:27 +00:00
|
|
|
/**
|
2001-10-02 03:10:56 +00:00
|
|
|
* Fill in an nsFont based on the ID of a system font. This function
|
|
|
|
* may or may not fill in the size, so the size should be set to a
|
|
|
|
* reasonable default before calling.
|
|
|
|
*
|
|
|
|
* @param aID The system font ID.
|
|
|
|
* @param aInfo The font structure to be filled in.
|
1999-01-21 23:55:27 +00:00
|
|
|
* @return error status
|
|
|
|
*/
|
2001-10-02 03:10:56 +00:00
|
|
|
NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const = 0;
|
1999-01-21 23:55:27 +00:00
|
|
|
|
1999-12-07 23:27:17 +00:00
|
|
|
/**
|
|
|
|
* Get the nsIFontMetrics that describe the properties of
|
|
|
|
* an nsFont.
|
|
|
|
* @param aFont font description to obtain metrics for
|
|
|
|
* @param aLangGroup the language group of the document
|
|
|
|
* @param aMetrics out parameter for font metrics
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
|
|
|
|
nsIFontMetrics*& aMetrics) = 0;
|
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Get the nsIFontMetrics that describe the properties of
|
|
|
|
* an nsFont.
|
|
|
|
* @param aFont font description to obtain metrics for
|
|
|
|
* @param aMetrics out parameter for font metrics
|
|
|
|
* @return error status
|
|
|
|
*/
|
1998-08-27 20:43:04 +00:00
|
|
|
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
//get and set the document zoom value used for display-time
|
|
|
|
//scaling. default is 1.0 (no zoom)
|
1998-08-27 18:47:22 +00:00
|
|
|
NS_IMETHOD SetZoom(float aZoom) = 0;
|
|
|
|
NS_IMETHOD GetZoom(float &aZoom) const = 0;
|
1998-05-05 22:11:50 +00:00
|
|
|
|
2002-02-16 16:24:25 +00:00
|
|
|
//get and set the text zoom value used for display-time scaling.
|
|
|
|
//default is 1.0 (no zoom). The device context doesn't do anything
|
|
|
|
//with this value. It's merely a convenient place to store it.
|
2000-04-02 21:47:15 +00:00
|
|
|
NS_IMETHOD SetTextZoom(float aTextZoom) = 0;
|
|
|
|
NS_IMETHOD GetTextZoom(float &aTextZoom) const = 0;
|
|
|
|
|
1998-08-01 21:37:40 +00:00
|
|
|
/**
|
|
|
|
* Check to see if a particular named font exists.
|
|
|
|
* @param aFontName character string of font face name
|
|
|
|
* @return NS_OK if font is available, else font is unavailable
|
|
|
|
*/
|
1998-08-07 02:12:34 +00:00
|
|
|
NS_IMETHOD CheckFontExistence(const nsString& aFaceName) = 0;
|
|
|
|
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName) = 0;
|
|
|
|
|
|
|
|
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
|
|
|
PRBool& aAliased) = 0;
|
1998-08-03 04:53:25 +00:00
|
|
|
|
2001-11-20 19:47:28 +00:00
|
|
|
/**
|
|
|
|
* Notification when a font metrics instance created for this device is
|
|
|
|
* about to be deleted
|
|
|
|
*/
|
|
|
|
NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics) = 0;
|
|
|
|
|
1998-12-02 00:36:08 +00:00
|
|
|
/**
|
|
|
|
* Attempt to free up resoruces by flushing out any fonts no longer
|
|
|
|
* referenced by anything other than the font cache itself.
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD FlushFontCache(void) = 0;
|
|
|
|
|
1998-08-05 15:26:15 +00:00
|
|
|
/**
|
|
|
|
* Return the bit depth of the device.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetDepth(PRUint32& aDepth) = 0;
|
|
|
|
|
2001-11-07 04:36:47 +00:00
|
|
|
/**
|
|
|
|
* Returns information about the device's palette capabilities.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo) = 0;
|
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Get the size of the displayable area of the output device
|
|
|
|
* in app units.
|
|
|
|
* @param aWidth out parameter for width
|
|
|
|
* @param aHeight out parameter for height
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) = 0;
|
|
|
|
|
2000-04-21 06:55:13 +00:00
|
|
|
/**
|
|
|
|
* Get the size of the content area of the output device in app units.
|
|
|
|
* This corresponds on a screen device, for instance, to the entire screen.
|
|
|
|
* @param aRect out parameter for full rect. Position (x,y) will be (0,0) or
|
|
|
|
* relative to the primary monitor if this is not the primary.
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetRect ( nsRect &aRect ) = 0;
|
|
|
|
|
1999-09-02 05:37:14 +00:00
|
|
|
/**
|
|
|
|
* Get the size of the content area of the output device in app units.
|
|
|
|
* This corresponds on a screen device, for instance, to the area reported
|
|
|
|
* by GetDeviceSurfaceDimensions, minus the taskbar (Windows) or menubar
|
|
|
|
* (Macintosh).
|
|
|
|
* @param aRect out parameter for client rect. Position (x,y) will be (0,0)
|
2000-04-21 06:55:13 +00:00
|
|
|
* adjusted for any upper/left non-client space if present or
|
|
|
|
* relative to the primary monitor if this is not the primary.
|
1999-09-02 05:37:14 +00:00
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetClientRect(nsRect &aRect) = 0;
|
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Returns a new nsIDeviceContext suitable for the device context
|
|
|
|
* specification passed in.
|
|
|
|
* @param aDevice a device context specification. this is a platform
|
|
|
|
* specific structure that only a platform specific device
|
|
|
|
* context can interpret.
|
|
|
|
* @param aContext out parameter for new device context. nsnull on
|
|
|
|
* failure to create new device context.
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
|
|
|
nsIDeviceContext *&aContext) = 0;
|
|
|
|
|
2002-05-07 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* This is enables the DeviceContext to anything it needs to do for Printing
|
|
|
|
* before Reflow and BeginDocument is where work can be done after reflow.
|
|
|
|
* @param aTitle - itle of Document
|
|
|
|
* @param aPrintToFileName - name of file to print to, if NULL then don't print to file
|
|
|
|
*
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD PrepareDocument(PRUnichar * aTitle,
|
|
|
|
PRUnichar* aPrintToFileName) = 0;
|
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
//XXX need to work out re-entrancy issues for these APIs... MMP
|
|
|
|
/**
|
|
|
|
* Inform the output device that output of a document is beginning
|
|
|
|
* Used for print related device contexts. Must be matched 1:1 with
|
|
|
|
* EndDocument().
|
|
|
|
* XXX needs to take parameters so that feedback can be given to the
|
|
|
|
* app regarding pagination progress and aborting print operations?
|
2002-05-07 12:03:37 +00:00
|
|
|
*
|
|
|
|
* @param aTitle - itle of Document
|
|
|
|
* @param aPrintToFileName - name of file to print to, if NULL then don't print to file
|
|
|
|
* @param aStartPage - starting page number (must be greater than zero)
|
|
|
|
* @param aEndPage - ending page number (must be less than or equal to number of pages)
|
|
|
|
*
|
1998-11-14 02:05:13 +00:00
|
|
|
* @return error status
|
|
|
|
*/
|
2002-05-07 12:03:37 +00:00
|
|
|
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
|
|
|
|
PRUnichar* aPrintToFileName,
|
|
|
|
PRInt32 aStartPage,
|
|
|
|
PRInt32 aEndPage) = 0;
|
1998-11-14 02:05:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Inform the output device that output of a document is ending.
|
|
|
|
* Used for print related device contexts. Must be matched 1:1 with
|
|
|
|
* BeginDocument()
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD EndDocument(void) = 0;
|
|
|
|
|
2002-02-12 13:33:39 +00:00
|
|
|
/**
|
|
|
|
* Inform the output device that output of a document is being aborted.
|
|
|
|
* Must be matched 1:1 with BeginDocument()
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD AbortDocument(void) = 0;
|
|
|
|
|
1998-11-14 02:05:13 +00:00
|
|
|
/**
|
|
|
|
* Inform the output device that output of a page is beginning
|
|
|
|
* Used for print related device contexts. Must be matched 1:1 with
|
|
|
|
* EndPage() and within a BeginDocument()/EndDocument() pair.
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD BeginPage(void) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inform the output device that output of a page is ending
|
|
|
|
* Used for print related device contexts. Must be matched 1:1 with
|
|
|
|
* BeginPage() and within a BeginDocument()/EndDocument() pair.
|
|
|
|
* @return error status
|
|
|
|
*/
|
|
|
|
NS_IMETHOD EndPage(void) = 0;
|
2001-11-03 14:59:39 +00:00
|
|
|
|
|
|
|
#ifdef NS_PRINT_PREVIEW
|
|
|
|
/**
|
|
|
|
* Set an Alternative Device Context where some of the calls
|
|
|
|
* are deferred to it
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Alternate Device Context
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turn on/off which types of information is retrived
|
|
|
|
* via the alt device context
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn) = 0;
|
|
|
|
#endif
|
|
|
|
|
2004-02-05 01:57:10 +00:00
|
|
|
protected:
|
|
|
|
float mTwipsToPixels;
|
|
|
|
float mPixelsToTwips;
|
|
|
|
float mAppUnitsToDevUnits;
|
|
|
|
float mDevUnitsToAppUnits;
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsIDeviceContext_h___ */
|