Fix bug 279510: remove all the pre-Carbon code and TARGET_CARBON #idfefs from gfx. Patch by Ludovic Hirlimann <qa-mozilla@hirlimann.net>, r=pink, sr=me

This commit is contained in:
smfr%smfr.org 2005-01-28 18:00:58 +00:00
Родитель 8eaec170ab
Коммит 20697ecb7f
22 изменённых файлов: 13 добавлений и 1293 удалений

Просмотреть файл

@ -64,129 +64,19 @@ enum {
inline void GetWindowUpdateRegion ( WindowPtr window, RgnHandle outUpdateRgn ) inline void GetWindowUpdateRegion ( WindowPtr window, RgnHandle outUpdateRgn )
{ {
#if TARGET_CARBON
::GetWindowRegion(window, kWindowUpdateRgn, outUpdateRgn); ::GetWindowRegion(window, kWindowUpdateRgn, outUpdateRgn);
#else
::CopyRgn(((WindowRecord*)window)->updateRgn, outUpdateRgn);
#endif
} }
inline void SetControlPopupMenuStuff ( ControlHandle control, MenuHandle menu, short aID ) inline void SetControlPopupMenuStuff ( ControlHandle control, MenuHandle menu, short aID )
{ {
#if TARGET_CARBON
::SetControlPopupMenuHandle ( control, menu ); ::SetControlPopupMenuHandle ( control, menu );
::SetControlPopupMenuID ( control, aID ); ::SetControlPopupMenuID ( control, aID );
#else
PopupPrivateData* popupData = (PopupPrivateData*)*((*control)->contrlData);
if (popupData) {
popupData->mHandle = menu;
popupData->mID = aID;
}
#endif
} }
inline WindowRef GetTheWindowList(void) inline WindowRef GetTheWindowList(void)
{ {
#if TARGET_CARBON
return GetWindowList(); return GetWindowList();
#else
return LMGetWindowList();
#endif
} }
#if !TARGET_CARBON
inline void GetPortHiliteColor(CGrafPtr port, RGBColor* color)
{
// is this really a color grafport?
if (port->portVersion & 0xC000)
{
GrafVars** grafVars = (GrafVars**)port->grafVars;
*color = (*grafVars)->rgbHiliteColor;
}
else
{
RGBColor fakeColor = { 0x0000, 0x0000, 0x0000};
*color = fakeColor;
}
}
inline Boolean IsPortOffscreen(CGrafPtr port)
{
return ((UInt16)port->portVersion == 0xC001);
}
inline Rect* GetRegionBounds(RgnHandle region, Rect* rect)
{
*rect = (**region).rgnBBox;
return rect;
}
inline Boolean IsRegionComplex(RgnHandle region)
{
return (**region).rgnSize != sizeof(MacRegion);
}
inline void GetPortVisibleRegion(CGrafPtr port, RgnHandle visRgn)
{
::CopyRgn(port->visRgn, visRgn);
}
inline void GetPortClipRegion(CGrafPtr port, RgnHandle clipRgn)
{
::CopyRgn(port->clipRgn, clipRgn);
}
inline short GetPortTextFace(CGrafPtr port)
{
return port->txFace;
}
inline short GetPortTextFont(CGrafPtr port)
{
return port->txFont;
}
inline short GetPortTextSize(CGrafPtr port)
{
return port->txSize;
}
inline Rect* GetPortBounds(CGrafPtr port, Rect* portRect)
{
*portRect = port->portRect;
return portRect;
}
inline PixMapHandle GetPortPixMap(CGrafPtr port)
{
return port->portPixMap;
}
inline Boolean IsRegionRectangular(RgnHandle rgn)
{
return (**rgn).rgnSize == 10;
}
inline GrafPtr GetQDGlobalsThePort()
{
return qd.thePort;
}
inline const BitMap * GetPortBitMapForCopyBits(CGrafPtr port)
{
return &((GrafPtr)port)->portBits;
}
inline OSErr AEGetDescData (const AEDesc * theAEDesc, void * dataPtr, Size maximumSize)
{
::BlockMoveData(*(theAEDesc->dataHandle), dataPtr, maximumSize);
return noErr;
}
#endif /* !TARGET_CARBON */
#endif /* CarbonHelpers_h__ */ #endif /* CarbonHelpers_h__ */

Просмотреть файл

@ -1,237 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Patrick C. Beard <beard@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* 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"),
* 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
* use your version of this file under the terms of the MPL, indicate your
* 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
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
nsCoreGraphicsGlue.cpp
Glue routines for Core Graphics on Mac OS X.
by Patrick C. Beard.
*/
#include <size_t.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <CFURL.h>
#include <CFBundle.h>
#include <CFString.h>
#include <MacErrors.h>
#include <Gestalt.h>
#include <Fonts.h>
#include <CGAffineTransform.h>
static CFBundleRef getBundle(CFStringRef frameworkPath)
{
CFBundleRef bundle = NULL;
// Make a CFURLRef from the CFString representation of the bundle's path.
// See the Core Foundation URL Services chapter for details.
CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, frameworkPath, kCFURLPOSIXPathStyle, true);
if (bundleURL != NULL) {
bundle = CFBundleCreate(NULL, bundleURL);
if (bundle != NULL)
CFBundleLoadExecutable(bundle);
CFRelease(bundleURL);
}
return bundle;
}
static void* getSystemFunction(CFStringRef functionName)
{
static CFBundleRef systemBundle = getBundle(CFSTR("/System/Library/Frameworks/System.framework"));
if (systemBundle) return CFBundleGetFunctionPointerForName(systemBundle, functionName);
return NULL;
}
static void* getQuartzFunction(CFStringRef functionName)
{
static CFBundleRef quartzBundle = getBundle(CFSTR("/System/Library/Frameworks/ApplicationServices.framework"));
if (quartzBundle) return CFBundleGetFunctionPointerForName(quartzBundle, functionName);
return NULL;
}
// Useful Carbon-CFM debugging tool, printf that goes to the system console.
typedef int (*vprintf_proc_ptr) (const char* format, va_list args);
static vprintf_proc_ptr system_vprintf = (vprintf_proc_ptr) getSystemFunction(CFSTR("vprintf"));
int std::printf(const char* format, ...)
{
int rv = 0;
va_list args;
va_start(args, format);
if (system_vprintf)
rv = system_vprintf(format, args);
va_end(args);
return rv;
}
// Dynamically loaded functions exported from ApplicationServices.framework.
#define quartz_proc_ptr(name) \
Quartz_ ## name ## _proc_ptr
#define quartz_func(name) \
Quartz_ ## name
#define decl_quartz_func(r_type, name, args) \
typedef r_type (*quartz_proc_ptr(name)) args; \
static quartz_proc_ptr(name) quartz_func(name) = (quartz_proc_ptr(name)) getQuartzFunction(CFSTR(#name)); \
r_type name args
#define call_quartz_func(name, args, err) \
return (quartz_func(name) ? quartz_func(name) args : err)
#define call_quartz_proc(name, args) \
if (quartz_func(name)) quartz_func(name) args
decl_quartz_func(OSStatus, QDBeginCGContext, (CGrafPtr inPort, CGContextRef * outContext))
{
call_quartz_func(QDBeginCGContext, (inPort, outContext), cfragNoSymbolErr);
}
decl_quartz_func(OSStatus, QDEndCGContext, (CGrafPtr inPort, CGContextRef * inoutContext))
{
call_quartz_func(QDEndCGContext, (inPort, inoutContext), cfragNoSymbolErr);
}
decl_quartz_func(OSStatus, ClipCGContextToRegion, (CGContextRef ctx, const Rect * portRect, RgnHandle region))
{
call_quartz_func(ClipCGContextToRegion, (ctx, portRect, region), cfragNoSymbolErr);
}
decl_quartz_func(void, CGContextScaleCTM, (CGContextRef ctx, float sx, float sy))
{
call_quartz_proc(CGContextScaleCTM, (ctx, sx, sy));
}
decl_quartz_func(void, CGContextTranslateCTM, (CGContextRef ctx, float tx, float ty))
{
call_quartz_proc(CGContextTranslateCTM, (ctx, tx, ty));
}
decl_quartz_func(void, CGContextBeginPath, (CGContextRef ctx))
{
call_quartz_proc(CGContextBeginPath, (ctx));
}
decl_quartz_func(void, CGContextMoveToPoint, (CGContextRef ctx, float x, float y))
{
call_quartz_proc(CGContextMoveToPoint, (ctx, x, y));
}
decl_quartz_func(void, CGContextAddLineToPoint, (CGContextRef ctx, float x, float y))
{
call_quartz_proc(CGContextAddLineToPoint, (ctx, x, y));
}
decl_quartz_func(void, CGContextAddLines, (CGContextRef ctx, const CGPoint points[], size_t count))
{
call_quartz_proc(CGContextAddLines, (ctx, points, count));
}
decl_quartz_func(void, CGContextFillRect, (CGContextRef ctx, CGRect rect))
{
call_quartz_proc(CGContextFillRect, (ctx, rect));
}
decl_quartz_func(void, CGContextStrokeRect, (CGContextRef ctx, CGRect rect))
{
call_quartz_proc(CGContextStrokeRect, (ctx, rect));
}
decl_quartz_func(void, CGContextSetRGBFillColor, (CGContextRef ctx, float r, float g, float b, float alpha))
{
call_quartz_proc(CGContextSetRGBFillColor, (ctx, r, g, b, alpha));
}
decl_quartz_func(void, CGContextSetRGBStrokeColor, (CGContextRef ctx, float r, float g, float b, float alpha))
{
call_quartz_proc(CGContextSetRGBStrokeColor, (ctx, r, g, b, alpha));
}
decl_quartz_func(void, CGContextSetFont, (CGContextRef ctx, CGFontRef font))
{
call_quartz_proc(CGContextSetFont, (ctx, font));
}
decl_quartz_func(void, CGContextSetFontSize, (CGContextRef ctx, float size))
{
call_quartz_proc(CGContextSetFontSize, (ctx, size));
}
decl_quartz_func(void, CGContextSelectFont, (CGContextRef ctx, const char * name, float size, CGTextEncoding textEncoding))
{
call_quartz_proc(CGContextSelectFont, (ctx, name, size, textEncoding));
}
decl_quartz_func(void, CGContextShowText, (CGContextRef ctx, const char * cstring, size_t length))
{
call_quartz_proc(CGContextShowText, (ctx, cstring, length));
}
decl_quartz_func(void, CGContextShowTextAtPoint, (CGContextRef ctx, float x, float y, const char * cstring, size_t length))
{
call_quartz_proc(CGContextShowTextAtPoint, (ctx, x, y, cstring, length));
}
decl_quartz_func(void, CGContextSetTextMatrix, (CGContextRef ctx, CGAffineTransform transform))
{
call_quartz_proc(CGContextSetTextMatrix, (ctx, transform));
}
decl_quartz_func(CGAffineTransform, CGContextGetTextMatrix, (CGContextRef ctx))
{
CGAffineTransform transform = { 0.0 };
call_quartz_func(CGContextGetTextMatrix, (ctx), transform);
}
decl_quartz_func(CGAffineTransform, CGAffineTransformScale, (CGAffineTransform t, float sx, float sy))
{
call_quartz_func(CGAffineTransformScale, (t, sx, sy), t);
}
decl_quartz_func(CGAffineTransform, CGAffineTransformTranslate, (CGAffineTransform t, float tx, float ty))
{
call_quartz_func(CGAffineTransformTranslate, (t, tx, ty), t);
}

Просмотреть файл

@ -38,11 +38,7 @@
#include "nsDeviceContextMac.h" #include "nsDeviceContextMac.h"
#include "nsRenderingContextMac.h" #include "nsRenderingContextMac.h"
#if TARGET_CARBON
#include "nsDeviceContextSpecX.h" #include "nsDeviceContextSpecX.h"
#else
#include "nsDeviceContextSpecMac.h"
#endif
#include "nsIPrintingContext.h" #include "nsIPrintingContext.h"
#include "nsString.h" #include "nsString.h"
#include "nsHashtable.h" #include "nsHashtable.h"
@ -648,11 +644,6 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDev
::GetPort(&curPort); ::GetPort(&curPort);
#if !TARGET_CARBON
THPrint thePrintRecord = ((nsDeviceContextSpecMac*)aDevice)->mPrtRec;
pix_Inch = (**thePrintRecord).prInfo.iHRes;
macDC->mPageRect = (**thePrintRecord).prInfo.rPage;
#else
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(aDevice); nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(aDevice);
if (printingContext) { if (printingContext) {
if (NS_FAILED(printingContext->GetPrinterResolution(&pix_Inch))) if (NS_FAILED(printingContext->GetPrinterResolution(&pix_Inch)))
@ -663,7 +654,7 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDev
pageRect.top = top, pageRect.left = left; pageRect.top = top, pageRect.left = left;
pageRect.bottom = bottom, pageRect.right = right; pageRect.bottom = bottom, pageRect.right = right;
} }
#endif
((nsDeviceContextMac*)aContext)->Init(curPort); ((nsDeviceContextMac*)aContext)->Init(curPort);
@ -688,23 +679,11 @@ NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle,
PRInt32 aStartPage, PRInt32 aStartPage,
PRInt32 aEndPage) PRInt32 aEndPage)
{ {
#if !TARGET_CARBON
GrafPtr thePort;
if(((nsDeviceContextSpecMac*)(this->mSpec).get())->mPrintManagerOpen) {
::GetPort(&mOldPort);
thePort = (GrafPtr)::PrOpenDoc(((nsDeviceContextSpecMac*)(this->mSpec).get())->mPrtRec,nsnull,nsnull);
((nsDeviceContextSpecMac*)(this->mSpec).get())->mPrinterPort = (TPrPort*)thePort;
SetPort(thePort);
}
return NS_OK;
#else
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec); nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
if (printingContext) if (printingContext)
rv = printingContext->BeginDocument(aStartPage, aEndPage); rv = printingContext->BeginDocument(aStartPage, aEndPage);
return rv; return rv;
#endif
} }
@ -714,19 +693,11 @@ GrafPtr thePort;
*/ */
NS_IMETHODIMP nsDeviceContextMac::EndDocument(void) NS_IMETHODIMP nsDeviceContextMac::EndDocument(void)
{ {
#if !TARGET_CARBON
if(((nsDeviceContextSpecMac*)(this->mSpec).get())->mPrintManagerOpen){
::SetPort(mOldPort);
::PrCloseDoc(((nsDeviceContextSpecMac*)(this->mSpec).get())->mPrinterPort);
}
return NS_OK;
#else
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec); nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
if (printingContext) if (printingContext)
rv = printingContext->EndDocument(); rv = printingContext->EndDocument();
return rv; return rv;
#endif
} }
/** --------------------------------------------------- /** ---------------------------------------------------
@ -745,17 +716,11 @@ NS_IMETHODIMP nsDeviceContextMac::AbortDocument(void)
*/ */
NS_IMETHODIMP nsDeviceContextMac::BeginPage(void) NS_IMETHODIMP nsDeviceContextMac::BeginPage(void)
{ {
#if !TARGET_CARBON
if(((nsDeviceContextSpecMac*)(this->mSpec).get())->mPrintManagerOpen)
::PrOpenPage(((nsDeviceContextSpecMac*)(this->mSpec).get())->mPrinterPort,nsnull);
return NS_OK;
#else
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec); nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
if (printingContext) if (printingContext)
rv = printingContext->BeginPage(); rv = printingContext->BeginPage();
return rv; return rv;
#endif
} }

Просмотреть файл

@ -40,11 +40,8 @@
#include "nsIPrintingContext.h" #include "nsIPrintingContext.h"
#include "nsGfxCIID.h" #include "nsGfxCIID.h"
#include "plstr.h" #include "plstr.h"
#if TARGET_CARBON
#include "nsDeviceContextSpecX.h" #include "nsDeviceContextSpecX.h"
#else
#include "nsDeviceContextSpecMac.h"
#endif
/** ------------------------------------------------------- /** -------------------------------------------------------
* Constructor * Constructor

Просмотреть файл

@ -1,145 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* 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"),
* 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
* use your version of this file under the terms of the MPL, indicate your
* 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
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecMac.h"
#include "nsIServiceManager.h"
#include "nsIPrintOptions.h"
#include "nsIPrintSettingsMac.h"
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecMac
* @update dc 12/02/98
*/
nsDeviceContextSpecMac::nsDeviceContextSpecMac()
: mPrtRec(nsnull)
, mPrintManagerOpen(PR_FALSE)
{
}
/** -------------------------------------------------------
* Destroy the nsDeviceContextSpecMac
* @update dc 12/02/98
*/
nsDeviceContextSpecMac::~nsDeviceContextSpecMac()
{
ClosePrintManager();
if (mPrtRec) {
::DisposeHandle((Handle)mPrtRec);
mPrtRec = nsnull;
}
}
NS_IMPL_ISUPPORTS2(nsDeviceContextSpecMac, nsIDeviceContextSpec, nsIPrintingContext)
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecMac
* @update dc 05/04/2001
*/
NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview)
{
nsCOMPtr<nsIPrintSettingsMac> printSettingsMac(do_QueryInterface(aPS));
if (!printSettingsMac)
return NS_ERROR_NO_INTERFACE;
// open the printing manager if not print preview
if (!aIsPrintPreview) {
::PrOpen();
if (::PrError() != noErr)
return NS_ERROR_FAILURE;
mPrintManagerOpen = PR_TRUE;
}
nsresult rv = printSettingsMac->GetTHPrint(&mPrtRec);
// make sure the print record is valid
::PrValidate(mPrtRec);
if (::PrError() != noErr)
return NS_ERROR_FAILURE;
return NS_OK;
}
/** -------------------------------------------------------
* Closes the printmanager if it is open.
* @update dc 12/03/98
*/
NS_IMETHODIMP nsDeviceContextSpecMac::ClosePrintManager()
{
if (mPrintManagerOpen)
::PrClose();
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecMac::BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage)
{
nsresult rv = NS_OK;
return rv;
}
NS_IMETHODIMP nsDeviceContextSpecMac::EndDocument()
{
nsresult rv = NS_OK;
return rv;
}
NS_IMETHODIMP nsDeviceContextSpecMac::BeginPage()
{
nsresult rv = NS_OK;
return rv;
}
NS_IMETHODIMP nsDeviceContextSpecMac::EndPage()
{
nsresult rv = NS_OK;
return rv;
}
NS_IMETHODIMP nsDeviceContextSpecMac::GetPrinterResolution(double* aResolution)
{
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
return rv;
}
NS_IMETHODIMP nsDeviceContextSpecMac::GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight)
{
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
return rv;
}

Просмотреть файл

@ -1,114 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* 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"),
* 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
* use your version of this file under the terms of the MPL, indicate your
* 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
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecMac_h___
#define nsDeviceContextSpecMac_h___
#include "nsIDeviceContextSpec.h"
#include "nsIPrintingContext.h"
#include "nsDeviceContextMac.h"
#include "nsIPrintSettings.h"
#include <Printing.h>
class nsDeviceContextSpecMac : public nsIDeviceContextSpec, public nsIPrintingContext {
public:
/**
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
* @update dc 12/02/98
*/
nsDeviceContextSpecMac();
NS_DECL_ISUPPORTS
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 12/02/98
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
* @return error status
*/
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
/**
* This will tell if the printmanager is currently open
* @update dc 12/03/98
* @param aIsOpen True or False depending if the printmanager is open
* @return error status
*/
NS_IMETHOD PrintManagerOpen(PRBool* aIsOpen) {*aIsOpen = mPrintManagerOpen; return NS_OK;}
/**
* Closes the printmanager if it is open.
* @update dc 12/03/98
* @return error status
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage);
NS_IMETHOD EndDocument();
NS_IMETHOD BeginPage();
NS_IMETHOD EndPage();
NS_IMETHOD GetPrinterResolution(double* aResolution);
NS_IMETHOD GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight);
protected:
/**
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
* @update dc 12/02/98
*/
virtual ~nsDeviceContextSpecMac();
protected:
THPrint mPrtRec; // the print record
PRBool mPrintManagerOpen; // tells if the print manager is open
#if !TARGET_CARBON
// pinkerton - obsolete APIs. Doesn't exist in carbon
TPrPort* mPrinterPort;
#endif
friend class nsDeviceContextMac;
};
#endif

Просмотреть файл

@ -49,20 +49,13 @@
#include "nsRegionMac.h" #include "nsRegionMac.h"
#include "nsScriptableRegion.h" #include "nsScriptableRegion.h"
#include "nsNativeThemeMac.h" #include "nsNativeThemeMac.h"
#if TARGET_CARBON
#include "nsDeviceContextSpecX.h" #include "nsDeviceContextSpecX.h"
#include "nsPrintOptionsX.h" #include "nsPrintOptionsX.h"
#include "nsPrintSessionX.h" #include "nsPrintSessionX.h"
#else
#include "nsDeviceContextSpecMac.h"
#include "nsPrintOptionsMac.h"
#include "nsPrintSession.h"
#endif
#include "nsDeviceContextSpecFactoryM.h" #include "nsDeviceContextSpecFactoryM.h"
#include "nsScreenManagerMac.h" #include "nsScreenManagerMac.h"
#include "nsBlender.h" #include "nsBlender.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsPrintOptionsMac.h"
#include "nsUnicodeMappingUtil.h" #include "nsUnicodeMappingUtil.h"
#include "gfxImageFrame.h" #include "gfxImageFrame.h"
@ -76,15 +69,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDrawingSurfaceMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDrawingSurfaceMac)
#if TARGET_CARBON
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsX) NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsX)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init)
#else
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsMac)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorMac)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
@ -139,22 +126,14 @@ static const nsModuleComponentInfo components[] =
NS_DRAWING_SURFACE_CID, NS_DRAWING_SURFACE_CID,
"@mozilla.org/gfx/drawing-surface;1", "@mozilla.org/gfx/drawing-surface;1",
nsDrawingSurfaceMacConstructor }, nsDrawingSurfaceMacConstructor },
#if TARGET_CARBON
{ "nsDeviceContextSpec", { "nsDeviceContextSpec",
NS_DEVICE_CONTEXT_SPEC_CID, NS_DEVICE_CONTEXT_SPEC_CID,
"@mozilla.org/gfx/devicecontextspec;1", "@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecXConstructor }, nsDeviceContextSpecXConstructor },
#else
{ "nsDeviceContextSpec",
NS_DEVICE_CONTEXT_SPEC_CID,
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecMacConstructor },
#endif
{ "nsDeviceContextSpecFactory", { "nsDeviceContextSpecFactory",
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
"@mozilla.org/gfx/devicecontextspecfactory;1", "@mozilla.org/gfx/devicecontextspecfactory;1",
nsDeviceContextSpecFactoryMacConstructor }, nsDeviceContextSpecFactoryMacConstructor },
#if TARGET_CARBON
{ "PrintSettings Service", { "PrintSettings Service",
NS_PRINTSETTINGSSERVICE_CID, NS_PRINTSETTINGSSERVICE_CID,
"@mozilla.org/gfx/printsettings-service;1", "@mozilla.org/gfx/printsettings-service;1",
@ -163,16 +142,6 @@ static const nsModuleComponentInfo components[] =
NS_PRINTSESSION_CID, NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1", "@mozilla.org/gfx/printsession;1",
nsPrintSessionXConstructor }, nsPrintSessionXConstructor },
#else
{ "PrintSettings Service",
NS_PRINTSETTINGSSERVICE_CID,
"@mozilla.org/gfx/printsettings-service;1",
nsPrintOptionsMacConstructor },
{ "Print Session",
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor },
#endif
{ "nsFontEnumerator", { "nsFontEnumerator",
NS_FONT_ENUMERATOR_CID, NS_FONT_ENUMERATOR_CID,
"@mozilla.org/gfx/fontenumerator;1", "@mozilla.org/gfx/fontenumerator;1",

Просмотреть файл

@ -54,14 +54,7 @@
*/ */
inline PRBool CurrentPortIsWMPort() inline PRBool CurrentPortIsWMPort()
{ {
#if TARGET_CARBON
return PR_FALSE; return PR_FALSE;
#else
GrafPtr curPort;
::GetPort(&curPort);
return (curPort == ::LMGetWMgrPort());
#endif
} }
@ -82,20 +75,6 @@ inline PRBool ValidateDrawingState()
if (CurrentPortIsWMPort() && (FrontWindow() != nil)) if (CurrentPortIsWMPort() && (FrontWindow() != nil))
return false; return false;
#if TARGET_CARBON
//if (! IsValidPort(curPort)) // rather slow
// return false;
#else
// all our ports should be onscreen or offscreen color graphics ports
// Onscreen ports have portVersion 0xC000, GWorlds have 0xC001.
#if DEBUG
if ((((UInt16)curPort->portVersion & 0xC000) != 0xC000) && !IsSIOUXWindow((GrafPtr)curPort))
return false;
#else
if ((((UInt16)curPort->portVersion & 0xC000) != 0xC000))
return false;
#endif
#endif
// see if the device is in the device list. If not, it probably means that // see if the device is in the device list. If not, it probably means that
// it's the device for an offscreen GWorld. In that case, the current port // it's the device for an offscreen GWorld. In that case, the current port

Просмотреть файл

@ -47,7 +47,7 @@
#include "imgScaler.h" #include "imgScaler.h"
#if 0 #if 0
#if TARGET_CARBON
// useful region debugging code. // useful region debugging code.
static OSStatus PrintRgnRectProc(UInt16 message, RgnHandle rgn, const Rect *inRect, void *refCon) static OSStatus PrintRgnRectProc(UInt16 message, RgnHandle rgn, const Rect *inRect, void *refCon)
{ {
@ -81,7 +81,6 @@ static void PrintRegionOutline(RgnHandle inRgn)
UInt32 rectCount = 0; UInt32 rectCount = 0;
::QDRegionToRects(inRgn, kQDParseRegionFromTopLeft, sCountRectProc, &rectCount); ::QDRegionToRects(inRgn, kQDParseRegionFromTopLeft, sCountRectProc, &rectCount);
} }
#endif // TARGET_CARBON
#endif #endif
#pragma mark - #pragma mark -

Просмотреть файл

@ -201,7 +201,6 @@ printf("told to draw at %ld %ld w %ld h %ld\n", inBoxRect.left, inBoxRect.top, i
void void
nsNativeThemeMac::DrawEditText ( const Rect& inBoxRect, PRBool inIsDisabled ) nsNativeThemeMac::DrawEditText ( const Rect& inBoxRect, PRBool inIsDisabled )
{ {
#if TARGET_CARBON
Pattern whitePat; Pattern whitePat;
::BackColor(whiteColor); ::BackColor(whiteColor);
::BackPat(GetQDGlobalsWhite(&whitePat)); ::BackPat(GetQDGlobalsWhite(&whitePat));
@ -209,14 +208,12 @@ nsNativeThemeMac::DrawEditText ( const Rect& inBoxRect, PRBool inIsDisabled )
ThemeDrawState drawState = inIsDisabled ? kThemeStateDisabled : kThemeStateActive; ThemeDrawState drawState = inIsDisabled ? kThemeStateDisabled : kThemeStateActive;
::DrawThemeEditTextFrame(&inBoxRect, drawState); ::DrawThemeEditTextFrame(&inBoxRect, drawState);
#endif
} }
void void
nsNativeThemeMac::DrawListBox ( const Rect& inBoxRect, PRBool inIsDisabled ) nsNativeThemeMac::DrawListBox ( const Rect& inBoxRect, PRBool inIsDisabled )
{ {
#if TARGET_CARBON
Pattern whitePat; Pattern whitePat;
::BackColor(whiteColor); ::BackColor(whiteColor);
::BackPat(GetQDGlobalsWhite(&whitePat)); ::BackPat(GetQDGlobalsWhite(&whitePat));
@ -224,7 +221,6 @@ nsNativeThemeMac::DrawListBox ( const Rect& inBoxRect, PRBool inIsDisabled )
ThemeDrawState drawState = inIsDisabled ? kThemeStateDisabled : kThemeStateActive; ThemeDrawState drawState = inIsDisabled ? kThemeStateDisabled : kThemeStateActive;
::DrawThemeListBoxFrame(&inBoxRect, drawState); ::DrawThemeListBoxFrame(&inBoxRect, drawState);
#endif
} }
@ -488,7 +484,6 @@ nsNativeThemeMac::GetWidgetBorder(nsIDeviceContext* aContext,
// XXX we should probably cache some of these metrics // XXX we should probably cache some of these metrics
#if TARGET_CARBON
switch ( aWidgetType ) { switch ( aWidgetType ) {
case NS_THEME_BUTTON: case NS_THEME_BUTTON:
@ -525,7 +520,6 @@ nsNativeThemeMac::GetWidgetBorder(nsIDeviceContext* aContext,
} }
} }
#endif
return NS_OK; return NS_OK;
} }
@ -547,7 +541,6 @@ nsNativeThemeMac::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
aResult->SizeTo(0,0); aResult->SizeTo(0,0);
*aIsOverridable = PR_TRUE; *aIsOverridable = PR_TRUE;
#if TARGET_CARBON
switch ( aWidgetType ) { switch ( aWidgetType ) {
case NS_THEME_BUTTON: case NS_THEME_BUTTON:
@ -686,7 +679,6 @@ nsNativeThemeMac::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
} }
} }
#endif
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -1,129 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* 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"),
* 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
* use your version of this file under the terms of the MPL, indicate your
* 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
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPrintOptionsMac.h"
#include "nsPrintSettingsMac.h"
#define MAC_OS_PAGE_SETUP_PREFNAME "print.macos.pagesetup"
/** ---------------------------------------------------
* See documentation in nsPrintOptionsMac.h
* @update 6/21/00 dwc
*/
nsPrintOptionsMac::nsPrintOptionsMac()
{
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
nsPrintOptionsMac::~nsPrintOptionsMac()
{
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
*/
NS_IMETHODIMP nsPrintOptionsMac::_CreatePrintSettings(nsIPrintSettings **_retval)
{
nsresult rv;
nsPrintSettingsMac* printSettings = new nsPrintSettingsMac(); // does not initially ref count
if (!printSettings)
return NS_ERROR_OUT_OF_MEMORY;
rv = printSettings->Init();
if (NS_FAILED(rv))
return rv;
return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
NS_IMETHODIMP
nsPrintOptionsMac::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* [noscript] voidPtr GetNativeData (in short aDataType); */
NS_IMETHODIMP
nsPrintOptionsMac::GetNativeData(PRInt16 aDataType, void * *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
#pragma mark -
nsresult
nsPrintOptionsMac::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
{
nsresult rv;
rv = nsPrintOptions::ReadPrefs(aPS, aPrefName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
nsCOMPtr<nsIPrintSettingsMac> printSettingsMac(do_QueryInterface(aPS));
if (!printSettingsMac)
return NS_ERROR_NO_INTERFACE;
rv = printSettingsMac->ReadPageSetupFromPrefs();
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsMac::ReadPageFormatFromPrefs() failed");
return NS_OK;
}
nsresult
nsPrintOptionsMac::WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
{
nsresult rv;
rv = nsPrintOptions::WritePrefs(aPS, aPrefName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
nsCOMPtr<nsIPrintSettingsMac> printSettingsMac(do_QueryInterface(aPS));
if (!printSettingsMac)
return NS_ERROR_NO_INTERFACE;
rv = printSettingsMac->WritePageSetupToPrefs();
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed");
return NS_OK;
}

Просмотреть файл

@ -1,71 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Travis Bogard <travis@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* 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"),
* 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
* use your version of this file under the terms of the MPL, indicate your
* 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
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPrintOptionsMac_h__
#define nsPrintOptionsMac_h__
#include "nsPrintOptionsImpl.h"
#include <Printing.h>
//*****************************************************************************
//*** nsPrintOptions
//*****************************************************************************
#if !TARGET_CARBON
class nsPrintOptionsMac : public nsPrintOptions
{
public:
nsPrintOptionsMac();
virtual ~nsPrintOptionsMac();
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
protected:
nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
};
#endif /* TARGET_CARBON */
#endif /* nsPrintOptionsMac_h__ */

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsWatchTask.h"
#include "nsPrintOptionsX.h" #include "nsPrintOptionsX.h"
#include "nsPrintSettingsX.h" #include "nsPrintSettingsX.h"

Просмотреть файл

@ -1,236 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* 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"),
* 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
* use your version of this file under the terms of the MPL, indicate your
* 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
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPrintSettingsMac.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIServiceManager.h"
#include "plbase64.h"
#include "prmem.h"
#include "nsGfxUtils.h"
// Constants
#define PRINTING_PREF_BRANCH "print."
#define MAC_OS_PAGE_SETUP_PREFNAME "macos.pagesetup"
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsMac,
nsPrintSettings,
nsIPrintSettingsMac)
/** ---------------------------------------------------
*/
nsPrintSettingsMac::nsPrintSettingsMac() :
mPrintRecord(nsnull)
{
}
/** ---------------------------------------------------
*/
nsPrintSettingsMac::nsPrintSettingsMac(const nsPrintSettingsMac& src) :
mPrintRecord(nsnull)
{
*this = src;
}
/** ---------------------------------------------------
*/
nsPrintSettingsMac::~nsPrintSettingsMac()
{
if (mPrintRecord)
::DisposeHandle((Handle)mPrintRecord);
}
/** ---------------------------------------------------
*/
nsPrintSettingsMac& nsPrintSettingsMac::operator=(const nsPrintSettingsMac& rhs)
{
if (this == &rhs) {
return *this;
}
nsPrintSettings::operator=(rhs);
if (mPrintRecord) {
::DisposeHandle((Handle)mPrintRecord);
mPrintRecord = nsnull;
}
Handle copyH = (Handle)rhs.mPrintRecord;
if (::HandToHand(&copyH) == noErr)
mPrintRecord = (THPrint)copyH;
return *this;
}
/** ---------------------------------------------------
*/
NS_IMETHODIMP nsPrintSettingsMac::Init()
{
// create the print style and print record
mPrintRecord = (THPrint)::NewHandleClear(sizeof(TPrint));
if (!mPrintRecord)
return NS_ERROR_OUT_OF_MEMORY;
::PrOpen();
if (::PrError() != noErr)
return NS_ERROR_FAILURE;
::PrintDefault(mPrintRecord);
::PrClose();
return NS_OK;
}
/** ---------------------------------------------------
*/
NS_IMETHODIMP nsPrintSettingsMac::GetTHPrint(THPrint *aThPrint)
{
NS_ENSURE_ARG_POINTER(aThPrint);
*aThPrint = nsnull;
if (!mPrintRecord)
return NS_ERROR_NOT_INITIALIZED;
Handle temp = (Handle)mPrintRecord;
if (::HandToHand(&temp) != noErr)
return NS_ERROR_OUT_OF_MEMORY;
*aThPrint = (THPrint)temp;
return NS_OK;
}
/** ---------------------------------------------------
*/
NS_IMETHODIMP nsPrintSettingsMac::SetTHPrint(THPrint aThPrint)
{
NS_ENSURE_ARG(aThPrint);
if (mPrintRecord) {
::DisposeHandle((Handle)mPrintRecord);
mPrintRecord = nsnull;
}
mPrintRecord = aThPrint;
if (::HandToHand((Handle *)&mPrintRecord) != noErr)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
/** ---------------------------------------------------
*/
NS_IMETHODIMP nsPrintSettingsMac::ReadPageSetupFromPrefs()
{
nsresult rv;
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch));
if (NS_FAILED(rv))
return rv;
nsXPIDLCString encodedData;
rv = prefBranch->GetCharPref(MAC_OS_PAGE_SETUP_PREFNAME, getter_Copies(encodedData));
if (NS_FAILED(rv))
return rv;
// decode the base64
PRInt32 encodedDataLen = strlen(encodedData.get());
char* decodedData = ::PL_Base64Decode(encodedData.get(), encodedDataLen, nsnull);
if (!decodedData)
return NS_ERROR_FAILURE;
if (((encodedDataLen * 3) / 4) >= sizeof(TPrint))
::BlockMoveData(decodedData, *mPrintRecord, sizeof(TPrint));
else
rv = NS_ERROR_FAILURE; // the data was too small
PR_Free(decodedData);
return rv;
}
/** ---------------------------------------------------
*/
NS_IMETHODIMP nsPrintSettingsMac::WritePageSetupToPrefs()
{
if (!mPrintRecord)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch));
if (NS_FAILED(rv))
return rv;
StHandleLocker locker((Handle)mPrintRecord);
nsXPIDLCString encodedData;
encodedData.Adopt(::PL_Base64Encode((char *)*mPrintRecord, sizeof(TPrint), nsnull));
if (!encodedData.get())
return NS_ERROR_OUT_OF_MEMORY;
return prefBranch->SetCharPref(MAC_OS_PAGE_SETUP_PREFNAME, encodedData);
}
//-------------------------------------------
nsresult nsPrintSettingsMac::_Clone(nsIPrintSettings **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
nsPrintSettingsMac *newSettings = new nsPrintSettingsMac(*this);
if (!newSettings)
return NS_ERROR_FAILURE;
*_retval = newSettings;
NS_ADDREF(*_retval);
return NS_OK;
}
//-------------------------------------------
nsresult nsPrintSettingsMac::_Assign(nsIPrintSettings *aPS)
{
nsPrintSettingsMac *printSettingsMac = dynamic_cast<nsPrintSettingsMac*>(aPS);
if (!printSettingsMac)
return NS_ERROR_UNEXPECTED;
*this = *printSettingsMac;
return NS_OK;
}

Просмотреть файл

@ -1,77 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* 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"),
* 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
* use your version of this file under the terms of the MPL, indicate your
* 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
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPrintSettingsMac_h__
#define nsPrintSettingsMac_h__
#include "nsPrintSettingsImpl.h"
#include "nsIPrintSettingsMac.h"
#include <Printing.h>
//*****************************************************************************
//*** nsPrintSettingsMac
//*****************************************************************************
#if !TARGET_CARBON
class nsPrintSettingsMac : public nsPrintSettings,
public nsIPrintSettingsMac
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIPRINTSETTINGSMAC
nsPrintSettingsMac();
virtual ~nsPrintSettingsMac();
nsresult Init();
protected:
nsPrintSettingsMac(const nsPrintSettingsMac& src);
nsPrintSettingsMac& operator=(const nsPrintSettingsMac& rhs);
nsresult _Clone(nsIPrintSettings **_retval);
nsresult _Assign(nsIPrintSettings *aPS);
THPrint mPrintRecord;
};
#endif /* TARGET_CARBON */
#endif /* nsPrintSettingsMac_h__ */

Просмотреть файл

@ -36,11 +36,7 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsScreenMac.h" #include "nsScreenMac.h"
#if TARGET_CARBON
#include <MacWindows.h> #include <MacWindows.h>
#else
#include <Menus.h>
#endif
nsScreenMac :: nsScreenMac ( GDHandle inScreen ) nsScreenMac :: nsScreenMac ( GDHandle inScreen )
: mScreen(inScreen) : mScreen(inScreen)
@ -81,11 +77,7 @@ nsScreenMac :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth
{ {
Rect adjustedRect; Rect adjustedRect;
#if TARGET_CARBON
::GetAvailableWindowPositioningBounds ( mScreen, &adjustedRect ); ::GetAvailableWindowPositioningBounds ( mScreen, &adjustedRect );
#else
SubtractMenuBar ( (**mScreen).gdRect, &adjustedRect );
#endif
*outLeft = adjustedRect.left; *outLeft = adjustedRect.left;
*outTop = adjustedRect.top; *outTop = adjustedRect.top;
@ -115,23 +107,3 @@ nsScreenMac :: GetColorDepth(PRInt32 *aColorDepth)
} // GetColorDepth } // GetColorDepth
#if !TARGET_CARBON
//
// SubtractMenuBar
//
// Take out the menu bar from the reported size of this screen, but only
// if it is the primary screen
//
void
nsScreenMac :: SubtractMenuBar ( const Rect & inScreenRect, Rect* outAdjustedRect )
{
// if the screen we're being asked about is the main screen (ie, has the menu
// bar), then subract out the menubar from the rect that we're returning.
*outAdjustedRect = inScreenRect;
if ( IsPrimaryScreen() )
outAdjustedRect->top += ::GetMBarHeight();
}
#endif

Просмотреть файл

@ -55,11 +55,6 @@ public:
private: private:
#if !TARGET_CARBON
// Take out the menu bar from the reported size of this screen.
void SubtractMenuBar ( const Rect & inScreenRect, Rect* outAdjustedRect ) ;
#endif
// are we the primary screen? Needed so we can sub out the menubar if // are we the primary screen? Needed so we can sub out the menubar if
// asked. // asked.
PRBool IsPrimaryScreen ( ) const { return (mScreen == ::GetMainDevice()); } PRBool IsPrimaryScreen ( ) const { return (mScreen == ::GetMainDevice()); }

Просмотреть файл

@ -34,6 +34,7 @@
* the terms of any one of the MPL, the GPL or the LGPL. * the terms of any one of the MPL, the GPL or the LGPL.
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include <Script.h> #include <Script.h>
#include "nsDeviceContextMac.h" #include "nsDeviceContextMac.h"
#include "plhash.h" #include "plhash.h"
@ -45,6 +46,7 @@
#include "nsIUnicodeEncoder.h" #include "nsIUnicodeEncoder.h"
#include "nsCompressedCharMap.h" #include "nsCompressedCharMap.h"
#include "nsMacUnicodeFontInfo.h" #include "nsMacUnicodeFontInfo.h"
#define BAD_FONT_NUM -1 #define BAD_FONT_NUM -1
#define BAD_SCRIPT 0x7f #define BAD_SCRIPT 0x7f

Просмотреть файл

@ -43,9 +43,11 @@
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsString.h" #include "nsString.h"
#include "nsCRT.h" #include "nsCRT.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#define BAD_FONT_NUM -1 #define BAD_FONT_NUM -1
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
nsUnicodeMappingUtil *nsUnicodeMappingUtil::gSingleton = nsnull; nsUnicodeMappingUtil *nsUnicodeMappingUtil::gSingleton = nsnull;

Просмотреть файл

@ -34,6 +34,7 @@
* the terms of any one of the MPL, the GPL or the LGPL. * the terms of any one of the MPL, the GPL or the LGPL.
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsUnicodeRenderingToolkit.h" #include "nsUnicodeRenderingToolkit.h"
#include "nsUnicodeFontMappingMac.h" #include "nsUnicodeFontMappingMac.h"
#include "nsUnicodeFallbackCache.h" #include "nsUnicodeFallbackCache.h"
@ -53,10 +54,10 @@
#include <FixMath.h> #include <FixMath.h>
#define BAD_FONT_NUM -1 #define BAD_FONT_NUM -1
#define BAD_SCRIPT 0x7F #define BAD_SCRIPT 0x7F
#define STACK_TRESHOLD 1000 #define STACK_TRESHOLD 1000
static NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID); static NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
//#define DISABLE_TEC_FALLBACK //#define DISABLE_TEC_FALLBACK

Просмотреть файл

@ -35,7 +35,6 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsWatchTask.h" #include "nsWatchTask.h"
#include <LowMem.h> #include <LowMem.h>
#include <Appearance.h> #include <Appearance.h>
@ -67,10 +66,6 @@ nsWatchTask :: nsWatchTask ( )
nsWatchTask :: ~nsWatchTask ( ) nsWatchTask :: ~nsWatchTask ( )
{ {
#if !TARGET_CARBON
if ( mInstallSucceeded )
::VRemove ( (QElemPtr)&mTask );
#endif
InitCursor(); InitCursor();
} }
@ -85,23 +80,6 @@ nsWatchTask :: ~nsWatchTask ( )
void void
nsWatchTask :: Start ( ) nsWatchTask :: Start ( )
{ {
#if !TARGET_CARBON
// get the watch cursor and lock it high
CursHandle watch = ::GetCursor ( watchCursor );
if ( !watch )
return;
mWatchCursor = **watch;
// setup the task
mTask.qType = vType;
mTask.vblAddr = NewVBLProc((VBLProcPtr)DoWatchTask);
mTask.vblCount = kRepeatInterval;
mTask.vblPhase = 0;
// install it
mInstallSucceeded = ::VInstall((QElemPtr)&mTask) == noErr;
#endif
} // Start } // Start
@ -121,11 +99,7 @@ nsWatchTask :: DoWatchTask ( nsWatchTask* inSelf )
{ {
if ( inSelf->mChecksum == 'mozz' ) { if ( inSelf->mChecksum == 'mozz' ) {
if ( !inSelf->mSuspended ) { if ( !inSelf->mSuspended ) {
#if TARGET_CARBON
PRBool busy = inSelf->mBusy; PRBool busy = inSelf->mBusy;
#else
PRBool busy = inSelf->mBusy && LMGetCrsrBusy();
#endif
if ( !busy ) { if ( !busy ) {
if ( ::TickCount() - inSelf->mTicks > kTicksToShowWatch ) { if ( ::TickCount() - inSelf->mTicks > kTicksToShowWatch ) {
::SetCursor ( &(inSelf->mWatchCursor) ); ::SetCursor ( &(inSelf->mWatchCursor) );
@ -138,11 +112,6 @@ nsWatchTask :: DoWatchTask ( nsWatchTask* inSelf )
// next frame in cursor animation // next frame in cursor animation
++inSelf->mAnimation; ++inSelf->mAnimation;
} }
#if !TARGET_CARBON
// reset the task to fire again
inSelf->mTask.vblCount = kRepeatInterval;
#endif
} // if valid checksum } // if valid checksum
} // DoWatchTask } // DoWatchTask

Просмотреть файл

@ -39,11 +39,11 @@
#ifndef WatchTask_h__ #ifndef WatchTask_h__
#define WatchTask_h__ #define WatchTask_h__
#ifndef XP_MACOSX #ifndef XP_MACOSX
#include <Retrace.h> #include <Retrace.h>
#endif #endif
#include <Quickdraw.h> #include <Quickdraw.h>
#include "prtypes.h" #include "prtypes.h"
#include "gfxCore.h" #include "gfxCore.h"
@ -87,9 +87,7 @@ private:
// the VBL task // the VBL task
static pascal void DoWatchTask(nsWatchTask* theTaskPtr) ; static pascal void DoWatchTask(nsWatchTask* theTaskPtr) ;
#if !TARGET_CARBON
VBLTask mTask; // this must be first!!
#endif
long mChecksum; // 'mozz' to validate we have real data at interrupt time (not needed?) long mChecksum; // 'mozz' to validate we have real data at interrupt time (not needed?)
void* mSelf; // so we can get back to |this| from the static routine void* mSelf; // so we can get back to |this| from the static routine
long mTicks; // last time the event loop was hit long mTicks; // last time the event loop was hit