r= mkaply@us.ibm.com
OS/2 bring up continues - OS/2 specific changes
This commit is contained in:
mkaply%us.ibm.com 2000-05-12 19:26:34 +00:00
parent 4759075517
commit b21a2a4d57
23 changed files with 966 additions and 356 deletions

View File

@ -75,6 +75,8 @@ OS_LIBS += $(NSPR_LIBS)
# I guess eventually we ought to use an xml dialog...
# XXX Have to copy files because rc is too stupid for an objdir build
MOZ_POST_DSO_LIB_COMMAND = rc $(RES_FILE)
$(SHARED_LIBRARY): $(OBJS) $(RES_FILE)
$(RES_FILE): $(srcdir)/libprint.rc

View File

@ -17,6 +17,14 @@
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
*
* Modifications to Mozilla code or documentation identified per MPL Section 3.3.
*
* Date Modified by Description of modification
* 05/10/2000 IBM Corp. Make it look more like Windows.
*/
// ToDo: nowt (except get rid of unicode hack)
@ -25,8 +33,9 @@
#include "libprint.h"
#include <stdio.h>
#include "nsISupports.h"
//#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsOS2.h"
#include "nsRenderingContextOS2.h"
@ -37,114 +46,236 @@
#include "nsPaletteOS2.h"
#include "nsDeviceContextSpecOS2.h"
#include "nsDeviceContextSpecFactoryO.h"
// nsGfxFactory.cpp - factory for creating os/2 graphics objects.
//#include "nsScriptableRegion.h"
#include "nsIImageManager.h"
//#include "nsScreenManagerWin.h"
#include "nsString.h"
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCFontEnumerator, NS_FONT_ENUMERATOR_CID);
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCImage, NS_IMAGE_CID);
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
static NS_DEFINE_IID(kCDrawingSurface, NS_DRAWING_SURFACE_CID);
static NS_DEFINE_IID(kImageManagerImpl, NS_IMAGEMANAGER_CID);
static NS_DEFINE_IID(kCScreenManager, NS_SCREENMANAGER_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kCScriptableRegion, NS_SCRIPTABLE_REGION_CID);
class nsGfxFactoryOS2 : public nsIFactory
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIFACTORY
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance( nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory( PRBool aLock) { return NS_OK; }
nsGfxFactoryOS2( const nsCID &aClass);
virtual ~nsGfxFactoryOS2();
nsGfxFactoryOS2(const nsCID &aClass);
~nsGfxFactoryOS2();
private:
nsCID mClassID;
};
nsGfxFactoryOS2::nsGfxFactoryOS2( const nsCID &aClass)
static int gUseAFunctions = 0;
nsGfxFactoryOS2::nsGfxFactoryOS2(const nsCID &aClass)
{
NS_INIT_REFCNT();
mClassID = aClass;
static int init = 0;
if (!init) {
init = 1;
/* OS2TODO
OSVERSIONINFO os;
os.dwOSVersionInfoSize = sizeof(os);
::GetVersionEx(&os);
if ((os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
(os.dwMajorVersion == 4) &&
(os.dwMinorVersion == 0) && // Windows 95 (not 98)
(::GetACP() == 932)) { // Shift-JIS (Japanese)
gUseAFunctions = 1;
}
*/
}
NS_INIT_REFCNT();
mClassID = aClass;
}
nsGfxFactoryOS2::~nsGfxFactoryOS2()
{
}
NS_IMPL_ISUPPORTS(nsGfxFactoryOS2,nsIFactory::GetIID())
nsresult nsGfxFactoryOS2::QueryInterface(const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
nsresult nsGfxFactoryOS2::CreateInstance( nsISupports *aOuter,
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *)(nsISupports*)this;
} else if (aIID.Equals(kIFactoryIID)) {
*aResult = (void *)(nsIFactory*)this;
}
if (*aResult == NULL) {
return NS_NOINTERFACE;
}
AddRef(); // Increase reference count for caller
return NS_OK;
}
NS_IMPL_ADDREF(nsGfxFactoryOS2);
NS_IMPL_RELEASE(nsGfxFactoryOS2);
nsresult nsGfxFactoryOS2::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if( !aResult)
return NS_ERROR_NULL_POINTER;
nsresult res;
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = 0;
*aResult = NULL;
nsISupports *inst = nsnull;
nsISupports *inst = nsnull;
PRBool already_addreffed = PR_FALSE;
if( mClassID.Equals( kCFontMetrics)) {
inst = new nsFontMetricsOS2;
}
else if( mClassID.Equals( kCDeviceContext)) {
inst = new nsDeviceContextOS2;
}
else if( mClassID.Equals( kCRenderingContext)) {
inst = (nsISupports *)((nsIRenderingContext*)new nsRenderingContextOS2);
}
else if( mClassID.Equals( kCImage)) {
inst = new nsImageOS2;
}
else if( mClassID.Equals( kCRegion)) {
inst = new nsRegionOS2;
}
else if( mClassID.Equals( kCBlender)) {
inst = new nsBlender;
}
else if( mClassID.Equals( kCDeviceContextSpec)) {
inst = new nsDeviceContextSpecOS2;
}
else if( mClassID.Equals( kCDeviceContextSpecFactory)) {
inst = new nsDeviceContextSpecFactoryOS2;
}
if (mClassID.Equals(kCFontMetrics)) {
nsFontMetricsOS2* fm;
if (gUseAFunctions) {
// NS_NEWXPCOM(fm, nsFontMetricsOS2A);
}
else {
NS_NEWXPCOM(fm, nsFontMetricsOS2);
}
inst = (nsISupports *)fm;
}
else if (mClassID.Equals(kCDeviceContext)) {
nsDeviceContextOS2* dc;
NS_NEWXPCOM(dc, nsDeviceContextOS2);
inst = (nsISupports *)dc;
}
else if (mClassID.Equals(kCRenderingContext)) {
nsRenderingContextOS2* rc;
if (gUseAFunctions) {
// NS_NEWXPCOM(rc, nsRenderingContextOS2A);
}
else {
NS_NEWXPCOM(rc, nsRenderingContextOS2);
}
inst = (nsISupports *)((nsIRenderingContext*)rc);
}
else if (mClassID.Equals(kCImage)) {
nsImageOS2* image;
NS_NEWXPCOM(image, nsImageOS2);
inst = (nsISupports *)image;
}
else if (mClassID.Equals(kCRegion)) {
nsRegionOS2* region;
NS_NEWXPCOM(region, nsRegionOS2);
inst = (nsISupports *)region;
}
else if (mClassID.Equals(kCBlender)) {
nsBlender* blender;
NS_NEWXPCOM(blender, nsBlender);
inst = (nsISupports *)blender;
}
// OS2TODO
/*else if (mClassID.Equals(kCDrawingSurface)) {
nsDrawingSurfaceOS2* ds;
NS_NEWXPCOM(ds, nsDrawingSurfaceOS2);
inst = (nsISupports *)((nsIDrawingSurface *)ds);
}*/
else if (mClassID.Equals(kCDeviceContextSpec)) {
nsDeviceContextSpecOS2* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecOS2);
inst = (nsISupports *)dcs;
}
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
nsDeviceContextSpecFactoryOS2* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryOS2);
inst = (nsISupports *)dcs;
}
else if (mClassID.Equals(kCScriptableRegion)) {
nsCOMPtr<nsIRegion> rgn;
NS_NEWXPCOM(rgn, nsRegionOS2);
/*if (rgn != nsnull) {
nsIScriptableRegion* scriptableRgn = new nsScriptableRegion(rgn);
inst = (nsISupports *)scriptableRgn;
}*/
}
else if (mClassID.Equals(kImageManagerImpl)) {
nsCOMPtr<nsIImageManager> iManager;
res = NS_NewImageManager(getter_AddRefs(iManager));
already_addreffed = PR_TRUE;
if (NS_SUCCEEDED(res))
{
res = iManager->QueryInterface(NS_GET_IID(nsISupports), (void**)&inst);
}
}
else if (mClassID.Equals(kCFontEnumerator)) {
/* OS2TODO
nsFontEnumeratorOS2* fe;
NS_NEWXPCOM(fe, nsFontEnumeratorOS2);
inst = (nsISupports *)fe;
*/
}
else if (mClassID.Equals(kCScreenManager)) {
/* OS2TODO
NS_NEWXPCOM(inst, nsScreenManagerOS2);
*/
}
if( !inst)
return NS_ERROR_OUT_OF_MEMORY;
if( inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (already_addreffed == PR_FALSE)
NS_ADDREF(inst); // Stabilize
res = inst->QueryInterface(aIID, aResult);
nsresult res = inst->QueryInterface(aIID, aResult);
if( NS_FAILED(res))
// We didn't get the right interface, so clean up
delete inst;
return res;
NS_RELEASE(inst); // Destabilize and avoid leaks. Avoid calling delete <interface pointer>
return res;
}
// This is a factory-factory: create a factory for the desired type.
nsresult nsGfxFactoryOS2::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
// return the proper factory to the caller
extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if( !aFactory)
return NS_ERROR_NULL_POINTER;
if (nsnull == aFactory) {
return NS_ERROR_NULL_POINTER;
}
*aFactory = new nsGfxFactoryOS2( aClass);
*aFactory = new nsGfxFactoryOS2(aClass);
if( !*aFactory)
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;
}
return (*aFactory)->QueryInterface( nsIFactory::GetIID(), (void**) aFactory);
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
}
// Module-level data ---------------------------------------------------------

View File

@ -17,6 +17,13 @@
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/11/2000 IBM Corp. Make it look more like Windows.
*/
#include "nsGfxDefs.h"
@ -34,50 +41,52 @@ nsImageOS2::nsImageOS2()
NS_INIT_REFCNT();
mInfo = 0;
mStride = 0;
mRowBytes = 0;
mImageBits = 0;
mBitmap = 0;
mAStride = 0;
mAImageBits = 0;
mARowBytes = 0;
mAlphaBits = 0;
mABitmap = 0;
mAlphaDepth = 0;
mAlphaLevel = 0;
mColorMap = 0;
mOptimized = PR_FALSE;
mIsOptimized = PR_FALSE;
mIsTopToBottom = PR_FALSE;
mDeviceDepth = 0;
}
nsImageOS2::~nsImageOS2()
{
Cleanup();
CleanUp(PR_TRUE);
}
nsresult nsImageOS2::Init( PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
nsMaskRequirements aMaskRequirements)
{
// Guard against memory leak in multiple init
Cleanup();
CleanUp(PR_TRUE);
// (copying windows code - what about monochrome? Oh well.)
NS_ASSERTION( aDepth == 24 || aDepth == 8, "Bad image depth");
// Work out size of bitmap to allocate
mStride = RASWIDTH(aWidth,aDepth);
mRowBytes = RASWIDTH(aWidth,aDepth);
// mStride = aWidth * aDepth;
// mRowBytes = aWidth * aDepth;
// if( aDepth < 8)
// mStride += 7;
// mStride /= 8;
// mRowBytes += 7;
// mRowBytes /= 8;
//
// // Make sure image width is 4byte aligned
// mStride = (mStride + 3) & ~0x3;
// mRowBytes = (mRowBytes + 3) & ~0x3;
SetDecodedRect(0,0,0,0); //init
mImageBits = new PRUint8 [ aHeight * mStride ];
mImageBits = new PRUint8 [ aHeight * mRowBytes ];
// Set up bitmapinfo header
int cols = -1;
@ -110,33 +119,37 @@ nsresult nsImageOS2::Init( PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
{
if( aMaskRequirements == nsMaskRequirements_kNeeds1Bit)
{
mAStride = (aWidth + 7) / 8;
mARowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
}
else
{
NS_ASSERTION( nsMaskRequirements_kNeeds8Bit == aMaskRequirements,
"unexpected mask depth");
mAStride = aWidth;
mARowBytes = aWidth;
mAlphaDepth = 8;
}
// 32-bit align each row
mAStride = (mAStride + 3) & ~0x3;
mARowBytes = (mARowBytes + 3) & ~0x3;
mAImageBits = new PRUint8 [ aHeight * mAStride];
mAlphaBits = new PRUint8 [ aHeight * mARowBytes];
}
return NS_OK;
}
void nsImageOS2::Cleanup()
void nsImageOS2::CleanUp(PRBool aCleanUpAll)
{
// OS2TODO to handle aCleanUpAll param
if( mImageBits) {
delete [] mImageBits; mImageBits = 0;
delete [] mImageBits;
mImageBits = 0;
}
if( mInfo) {
free( mInfo); mInfo = 0;
free( mInfo);
mInfo = 0;
}
if( mColorMap) {
if( mColorMap->Index)
@ -144,8 +157,9 @@ void nsImageOS2::Cleanup()
delete mColorMap;
mColorMap = 0;
}
if( mAImageBits) {
delete [] mAImageBits; mAImageBits = 0;
if( mAlphaBits) {
delete [] mAlphaBits;
mAlphaBits = 0;
}
if( mBitmap) {
GpiDeleteBitmap( mBitmap);
@ -219,7 +233,7 @@ nsresult nsImageOS2::Draw( nsIRenderingContext &aContext,
// (b) is allegedly more efficient...
//
#if 0
if( mBitmap == 0 && mOptimized)
if( mBitmap == 0 && mIsOptimized)
{
// moz has asked us to optimize this image, but we haven't got
// round to actually doing it yet. So do it now.
@ -269,7 +283,7 @@ nsresult nsImageOS2::Draw( nsIRenderingContext &aContext,
nsresult nsImageOS2::Optimize( nsIDeviceContext* aContext)
{
// Defer this until we have a PS...
mOptimized = PR_TRUE;
mIsOptimized = PR_TRUE;
return NS_OK;
}
@ -306,7 +320,7 @@ void nsImageOS2::CreateBitmaps( nsDrawingSurfaceOS2 *surf)
if( mBitmap == GPI_ERROR)
PMERROR("GpiCreateBitmap");
if( mAImageBits)
if( mAlphaBits)
{
if( mAlphaDepth == 1)
{
@ -314,7 +328,7 @@ void nsImageOS2::CreateBitmaps( nsDrawingSurfaceOS2 *surf)
mABitmap = GpiCreateBitmap( surf->mPS,
maskInfo,
CBM_INIT,
(PBYTE) mAImageBits,
(PBYTE) mAlphaBits,
maskInfo);
if( mABitmap == GPI_ERROR)
PMERROR( "GpiCreateBitmap (mask)");
@ -347,7 +361,7 @@ void nsImageOS2::DrawBitmap( HPS hps, LONG lCount, PPOINTL pPoints,
pBmp2 = *pMaskInfo;
}
void *pBits = bIsMask ? mAImageBits : mImageBits;
void *pBits = bIsMask ? mAlphaBits : mImageBits;
if( GPI_ERROR == GpiDrawBits( hps, pBits, pBmp2,
lCount, pPoints, lRop, BBO_OR))

View File

@ -17,6 +17,12 @@
*
* Contributor(s):
*
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/11/2000 IBM Corp. Make it look more like Windows.
*/
#ifndef _nsImageOS2_h_
@ -26,78 +32,176 @@
struct nsDrawingSurfaceOS2;
class nsImageOS2 : public nsIImage
{
public:
nsImageOS2();
virtual ~nsImageOS2();
class nsImageOS2 : public nsIImage{
public:
nsImageOS2();
~nsImageOS2();
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
nsresult Init( PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
nsMaskRequirements aMaskRequirements);
PRInt32 GetWidth() { return mInfo ? mInfo->cx : 0; }
PRInt32 GetHeight() { return mInfo ? mInfo->cy : 0; }
PRInt32 GetLineStride() { return mStride; }
PRUint8 *GetBits() { return mImageBits; }
void *GetBitInfo() { return mInfo; }
nsColorMap *GetColorMap() { return mColorMap; }
PRInt32 GetBytesPix() { return mInfo ? mInfo->cBitCount : 0; }
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
virtual PRInt32 GetDecodedX1() { return mDecodedX1;}
virtual PRInt32 GetDecodedY1() { return mDecodedY1;}
virtual PRInt32 GetDecodedX2() { return mDecodedX2;}
virtual PRInt32 GetDecodedY2() { return mDecodedY2;}
/**
@see nsIImage.h
*/
virtual PRInt32 GetBytesPix() { return mInfo ? mInfo->cBitCount : 0; }
virtual PRInt32 GetHeight() { return mInfo ? mInfo->cy : 0; }
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
virtual PRInt32 GetWidth() { return mInfo ? mInfo->cx : 0; }
virtual PRUint8* GetBits() { return mImageBits; }
virtual PRInt32 GetLineStride() { return mRowBytes; }
PRBool GetIsRowOrderTopToBottom() { return PR_FALSE; }
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
virtual PRInt32 GetDecodedX1() { return mDecodedX1;}
virtual PRInt32 GetDecodedY1() { return mDecodedY1;}
virtual PRInt32 GetDecodedX2() { return mDecodedX2;}
virtual PRInt32 GetDecodedY2() { return mDecodedY2;}
// These may require more sensible returns...
PRInt32 GetAlphaWidth() { return mInfo ? mInfo->cx : 0; }
PRInt32 GetAlphaHeight() { return mInfo ? mInfo->cy : 0; }
PRInt32 GetAlphaLineStride() { return mAStride; }
PRBool GetHasAlphaMask() { return mAImageBits != nsnull; }
PRUint8 *GetAlphaBits() { return mAImageBits; }
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
void SetAlphaLevel(PRInt32 aAlphaLevel) {}
PRInt32 GetAlphaLevel() { return 0; }
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual nsColorMap* GetColorMap() {return mColorMap;}
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized() { return mIsOptimized; }
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRUint8* GetAlphaBits() { return mAlphaBits; }
virtual PRInt32 GetAlphaWidth() { return mInfo ? mInfo->cx : 0; }
virtual PRInt32 GetAlphaHeight() { return mInfo ? mInfo->cy : 0; }
virtual PRInt32 GetAlphaLineStride(){ return mARowBytes; }
nsresult Optimize( nsIDeviceContext* aContext);
PRBool IsOptimized() { return mOptimized; }
/**
* Draw a tiled version of the bitmap
* @update - dwc 3/30/00
* @param aSurface the surface to blit to
* @param aX The destination horizontal location
* @param aY The destination vertical location
* @param aWidth The destination width of the pixelmap
* @param aHeight The destination height of the pixelmap
* @return if TRUE, no errors
*/
#if 0 // OS2TODO
PRBool DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,nscoord aWidth,nscoord aHeight);
#endif
NS_IMETHOD Draw( nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw( nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
/**
* Return the header size of the Device Independent Bitmap(DIB).
* @return size of header in bytes
*/
#if 0 // OS2TODO
PRIntn GetSizeHeader(){return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * mNumPaletteColors;}
#endif
void ImageUpdated( nsIDeviceContext *aContext,
PRUint8 aFlags, nsRect *aUpdateRect);
/**
* Return the image size of the Device Independent Bitmap(DIB).
* @update dc - 10/29/98
* @return size of image in bytes
*/
#if 0 // OS2TODO
PRIntn GetSizeImage(){ return mSizeImage; }
#endif
/**
* Calculate the number of bytes spaned for this image for a given width
* @param aWidth is the width to calculate the number of bytes for
* @return the number of bytes in this span
*/
#if 0 // OS2TODO
PRInt32 CalcBytesSpan(PRUint32 aWidth);
#endif
virtual void SetAlphaLevel(PRInt32 aAlphaLevel) {mAlphaLevel=aAlphaLevel;}
/**
* Get the alpha level assigned.
* @update dc - 10/29/98
* @return The alpha level from 0 to 1
*/
virtual PRInt32 GetAlphaLevel() {return(mAlphaLevel);}
/**
* Get the DIB specific informations for this bitmap.
* @update dc - 10/29/98
* @return VOID
*/
void* GetBitInfo() { return mInfo; }
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
private:
BITMAPINFO2 *mInfo;
PRInt32 mStride;
PRInt32 mAStride;
PRUint8 *mImageBits;
PRUint8 *mAImageBits;
nsColorMap *mColorMap;
HBITMAP mBitmap;
HBITMAP mABitmap;
PRBool mOptimized;
PRInt32 mAlphaDepth;
PRUint32 mDeviceDepth;
/**
* Clean up the memory used nsImageWin.
* @update dc - 10/29/98
* @param aCleanUpAll - if True, all the memory used will be released otherwise just clean up the DIB memory
*/
void CleanUp(PRBool aCleanUpAll);
PRInt32 mDecodedX1; //Keeps track of what part of image
PRInt32 mDecodedY1; // has been decoded.
PRInt32 mDecodedX2;
PRInt32 mDecodedY2;
#ifdef OS2TODO
/**
* Create a Device Dependent bitmap from a drawing surface
* @update dc - 10/29/98
* @param aSurface - The drawingsurface to create the DDB from.
*/
void CreateDDB(nsDrawingSurface aSurface);
void Cleanup();
void CreateBitmaps( nsDrawingSurfaceOS2 *surf);
void DrawBitmap( HPS hps, LONG cPts, PPOINTL pPts, LONG lRop, PRBool bMsk);
/**
* Create a Device Dependent bitmap from a drawing surface
* @update dc - 05/20/99
* @param aSurface - The drawingsurface to create the DIB from.
* @param aWidth - width of DIB
* @param aHeight - height of DIB
*/
nsresult ConvertDDBtoDIB(PRInt32 aWidth,PRInt32 aHeight);
/**
* Print a DDB
* @update dc - 05/20/99
* @param aSurface - The drawingsurface to create the DIB from.
* @param aX - x location to place image
* @param aX - y location to place image
* @param aWidth - width of DIB
* @param aHeight - height of DIB
*/
nsresult PrintDDB(nsDrawingSurface aSurface,PRInt32 aX,PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight);
/**
* Get an index in the palette that matches as closly as possible the passed in RGB colors
* @update dc - 10/29/98
* @param aR - Red component of the color to match
* @param aG - Green component of the color to match
* @param aB - Blue component of the color to match
* @return - The closest palette match
*/
PRUint8 PaletteMatch(PRUint8 r, PRUint8 g, PRUint8 b);
#endif
BITMAPINFO2* mInfo;
PRBool mIsTopToBottom; // rows in image are top to bottom
HBITMAP mBitmap;
HBITMAP mABitmap;
PRUint32 mDeviceDepth;
PRInt32 mRowBytes; // number of bytes per row
PRUint8* mImageBits; // starting address of DIB bits
PRBool mIsOptimized; // Did we convert our DIB to a HBITMAP
nsColorMap* mColorMap; // Redundant with mColorTable, but necessary
PRInt32 mDecodedX1; //Keeps track of what part of image
PRInt32 mDecodedY1; // has been decoded.
PRInt32 mDecodedX2;
PRInt32 mDecodedY2;
// alpha layer members
PRUint8 *mAlphaBits; // alpha layer if we made one
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mARowBytes; // number of bytes per row in the image for tha alpha
PRInt16 mAlphaLevel; // an alpha level every pixel uses
void CreateBitmaps( nsDrawingSurfaceOS2 *surf);
void DrawBitmap( HPS hps, LONG cPts, PPOINTL pPts, LONG lRop, PRBool bMsk);
};
#endif

View File

@ -17,6 +17,12 @@
*
* Contributor(s):
*
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/08/2000 IBM Corp. Fix for trying to us an already freed mGammaTable.
*/
// ToDo: nothing
@ -52,8 +58,12 @@ class nsPaletteOS2 : public nsIPaletteOS2
return mContext == nsnull ? NS_ERROR_FAILURE : NS_OK;
}
long GetGPIColor( HPS hps, nscolor rgb)
long GetGPIColor( nsIDeviceContext *aContext, HPS hps, nscolor rgb)
{
if (mContext != aContext) {
mContext = aContext;
mContext->GetGammaTable( mGammaTable);
}
long gcolor = MK_RGB( mGammaTable[NS_GET_R(rgb)],
mGammaTable[NS_GET_G(rgb)],
mGammaTable[NS_GET_B(rgb)]);

View File

@ -17,6 +17,12 @@
*
* Contributor(s):
*
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/08/2000 IBM Corp. Fix for trying to us an already freed mGammaTable.
*/
// Manage picking of colours via various GPI methods.
@ -38,7 +44,7 @@ class nsIDeviceContext;
class nsIPaletteOS2 : public nsISupports
{
public:
virtual long GetGPIColor( HPS hps, nscolor rgb) = 0;
virtual long GetGPIColor( nsIDeviceContext *aContext, HPS hps, nscolor rgb) = 0;
virtual nsresult Select( HPS hps, nsIDeviceContext *aContext) = 0;
virtual nsresult Deselect( HPS hps) = 0;
virtual nsresult GetNSPalette( nsPalette &aPalette) const = 0;

View File

@ -17,6 +17,12 @@
*
* Contributor(s):
*
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/110/2000 IBM Corp. Make more like Windows
*/
// Region object. From os2fe\regions.cpp.
@ -31,50 +37,49 @@ typedef void (*nsRECTLInRegionFunc)(void *closure, RECTL &rectl);
class nsRegionOS2 : public nsIRegion
{
public:
nsRegionOS2();
virtual ~nsRegionOS2();
NS_DECL_ISUPPORTS
NS_IMETHOD Init();
virtual void SetTo( const nsIRegion &aRegion);
virtual void SetTo( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Intersect( const nsIRegion &aRegion);
virtual void Intersect( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union( const nsIRegion &aRegion);
virtual void Union( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract( const nsIRegion &aRegion);
virtual void Subtract( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty();
virtual PRBool IsEqual( const nsIRegion &aRegion);
virtual void GetBoundingBox( PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset( PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
public:
nsRegionOS2();
NS_IMETHOD GetRects( nsRegionRectSet **aRects);
NS_IMETHOD FreeRects( nsRegionRectSet *aRects);
NS_DECL_ISUPPORTS
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
// Don't use this -- it returns a region defined in CRS.
NS_IMETHOD GetNativeRegion( void *&aRegion) const;
NS_IMETHOD GetRegionComplexity( nsRegionComplexity &aComplexity) const;
virtual nsresult Init();
virtual void SetTo(const nsIRegion &aRegion);
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Intersect(const nsIRegion &aRegion);
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union(const nsIRegion &aRegion);
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract(const nsIRegion &aRegion);
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty(void);
virtual PRBool IsEqual(const nsIRegion &aRegion);
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const; // Don't use this -- it returns a region defined in CRS.
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
// OS/2 specific
// get region in widget's coord space for given device
HRGN GetHRGN( PRUint32 ulHeight, HPS hps);
// OS/2 specific
// get region in widget's coord space for given device
HRGN GetHRGN( PRUint32 ulHeight, HPS hps);
// copy from another region defined in aWidget's space for a given device
nsresult Init( HRGN copy, PRUint32 ulHeight, HPS hps);
// copy from another region defined in aWidget's space for a given device
nsresult Init( HRGN copy, PRUint32 ulHeight, HPS hps);
private:
void combine( long lOp, PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt32 aH);
void combine( long lOp, const nsIRegion &aRegion);
private:
~nsRegionOS2();
HRGN mRegion;
long mRegionType;
void combine( long lOp, PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt32 aH);
void combine( long lOp, const nsIRegion &aRegion);
};
#endif

View File

@ -29,6 +29,7 @@
*
* Date Modified by Description of modification
* 03/23/2000 IBM Corp. Fixed InvertRect.
* 05/08/2000 IBM Corp. Fix for trying to us an already freed mGammaTable.
*
*/
@ -825,7 +826,7 @@ void nsRenderingContextOS2::SetupDrawingColor( BOOL bForce)
{
if( bForce || mColor != mCurrDrawingColor)
{
long lColor = mPalette->GetGPIColor( mSurface->mPS, mColor);
long lColor = mPalette->GetGPIColor( mContext, mSurface->mPS, mColor);
GpiSetAttrs( mSurface->mPS, PRIM_LINE, LBB_COLOR, 0, &lColor);
GpiSetAttrs( mSurface->mPS, PRIM_AREA, ABB_COLOR, 0, &lColor);
mCurrDrawingColor = mColor;
@ -861,7 +862,7 @@ void nsRenderingContextOS2::SetupFontAndColor( BOOL bForce)
if( bForce || mColor != mCurrTextColor)
{
long lColor = mPalette->GetGPIColor( mSurface->mPS, mColor);
long lColor = mPalette->GetGPIColor( mContext, mSurface->mPS, mColor);
GpiSetAttrs( mSurface->mPS, PRIM_CHAR, CBB_COLOR, 0, &lColor);
mCurrTextColor = mColor;
}

View File

@ -17,16 +17,23 @@
*
* Contributor(s): Henry Sobotka <sobotka@axess.com>
*
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/11/2000 IBM Corp. Make more like Windows.
*/
#ifndef _nsRenderingContextOS2_h
#define _nsRenderingContextOS2_h
#include "nsIRenderingContext.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nscoord.h"
#include "nscolor.h"
#include "nsCRT.h"
#include "nsDrawingSurfaceOS2.h"
#include "nsRenderingContextImpl.h"
class nsIDeviceContext;
class nsIFontMetrics;
@ -37,137 +44,154 @@ class nsPoint;
class nsFont;
class nsRect;
struct GraphicsState;
class GraphicsState;
class nsDrawingSurfaceOS2;
#include "nsDrawingSurfaceOS2.h"
class nsRenderingContextOS2 : public nsIRenderingContext
class nsRenderingContextOS2 : public nsRenderingContextImpl
{
public:
nsRenderingContextOS2();
virtual ~nsRenderingContextOS2();
public:
nsRenderingContextOS2();
void *operator new( size_t sz) {
void *rv = new char[ sz];
nsCRT::zero( rv, sz);
return rv;
}
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
NS_IMETHOD Init( nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init( nsIDeviceContext* aContext, nsDrawingSurface aSurface);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
NS_IMETHOD Reset();
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext( nsIDeviceContext *&aDeviceContext);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD LockDrawingSurface( PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits,
PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface();
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface(void);
NS_IMETHOD SelectOffScreenDrawingSurface( nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface( nsDrawingSurface *aSurface);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState();
NS_IMETHOD PopState( PRBool &aClipEmpty);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipState);
NS_IMETHOD IsVisibleRect( const nsRect& aRect, PRBool &aIsVisible);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aClipState);
NS_IMETHOD SetClipRect( const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRect( nsRect &aRect, PRBool &aHasLocalClip);
NS_IMETHOD SetClipRegion( const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRegion( nsIRegion **aRegion);
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aCilpState);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipState);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipState);
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetColor( nscolor aColor);
NS_IMETHOD GetColor( nscolor &aColor) const;
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetFont( const nsFont& aFont);
NS_IMETHOD SetFont( nsIFontMetrics *aFontMetrics);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD GetFontMetrics( nsIFontMetrics*& aFontMetrics);
NS_IMETHOD SetFont(const nsFont& aFont);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD Translate( nscoord aX, nscoord aY);
NS_IMETHOD Scale( float aSx, float aSy);
NS_IMETHOD GetCurrentTransform( nsTransform2D *&aTransform);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD SetLineStyle( nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle( nsLineStyle &aLineStyle);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface( nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface( nsDrawingSurface aDS);
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine( nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline( const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect( const nsRect& aRect);
NS_IMETHOD DrawRect( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect( const nsRect& aRect);
NS_IMETHOD FillRect( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD InvertRect(const nsRect& aRect);
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon( const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon( const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD InvertRect(const nsRect& aRect);
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawEllipse( const nsRect& aRect);
NS_IMETHOD DrawEllipse( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse( const nsRect& aRect);
NS_IMETHOD FillEllipse( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawArc( const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc( const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
// String widths
NS_IMETHOD GetWidth( char aC, nscoord &aWidth);
NS_IMETHOD GetWidth( PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID = nsnull);
NS_IMETHOD GetWidth( const nsString &aString, nscoord &aWidth,
PRInt32 *aFontID = nsnull);
NS_IMETHOD GetWidth( const char* aString, nscoord &aWidth);
NS_IMETHOD GetWidth( const char* aString, PRUint32 aLength,
nscoord &aWidth);
NS_IMETHOD GetWidth( const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID = nsnull);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord& aWidth);
NS_IMETHOD GetWidth( PRUnichar aC, nscoord& aWidth,
PRInt32 *aFontID = nsnull);
NS_IMETHOD GetWidth( const nsString& aString, nscoord& aWidth,
PRInt32 *aFontID = nsnull);
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth( const PRUnichar* aString, PRUint32 aLength,
nscoord& aWidth, PRInt32 *aFontID = nsnull);
#if 0 // OS2TODO
NS_IMETHOD GetWidth(const PRUnichar *aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nscoord& aWidth,
PRInt32& aNumCharsFit,
PRInt32* aFontID);
#endif
NS_IMETHOD DrawString( const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing = nsnull);
NS_IMETHOD DrawString( const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
NS_IMETHOD DrawString( const nsString& aString,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
NS_IMETHOD DrawString( const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing = nsnull);
NS_IMETHOD DrawString( const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
NS_IMETHOD DrawString( const nsString& aString,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
NS_IMETHOD DrawImage( nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage( nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage( nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage( nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
nscoord aWidth,nscoord aHeight);
NS_IMETHOD CopyOffScreenBits( nsDrawingSurface aSrcSurf,
PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds,
PRUint32 aCopyFlags);
NS_IMETHOD GetHints( PRUint32 &aResult);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
//~~~
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
#if 0 // OS2TODO
#ifdef MOZ_MATHML
NS_IMETHOD
GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
NS_IMETHOD
GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID);
#endif
#endif
// Convert XP-rects to OS/2 space.
// World coordinates given & required, double inclusive rcl wanted.
@ -182,26 +206,36 @@ class nsRenderingContextOS2 : public nsIRenderingContext
// Convert XP points to OS/2 space.
void NS2PM( PPOINTL aPointl, ULONG cPointls);
private:
nsresult CommonInit();
nsresult SetupPS( HPS oldPS, HPS newPS);
void GetTargetHeight( PRUint32 &ht);
// Colour/font setting; call before drawing things.
void SetupDrawingColor( BOOL bForce = FALSE);
void SetupFontAndColor( BOOL bForce = FALSE);
// Primitive draw-ers
void PMDrawRect( nsRect &rect, BOOL fill);
void PMDrawPoly( const nsPoint aPoints[], PRInt32 aNumPoints, PRBool bFilled);
void PMDrawArc( nsRect &rect, PRBool bFilled, PRBool bFull, PRInt32 start=0, PRInt32 end=0);
private:
// ConditionRect is used to fix coordinate overflow problems for
// rectangles after they are transformed to screen coordinates
NS_IMETHOD ConditionRect( nscoord &x, nscoord &y, nscoord &w, nscoord &h );
// ConditionRect is used to fix coordinate overflow problems for
// rectangles after they are transformed to screen coordinates
NS_IMETHOD ConditionRect( nscoord &x, nscoord &y, nscoord &w, nscoord &h );
nsresult CommonInit(void);
nsresult SetupPS( HPS oldPS, HPS newPS);
void GetTargetHeight( PRUint32 &ht);
// Colour/font setting; call before drawing things.
void SetupDrawingColor( BOOL bForce = FALSE);
void SetupFontAndColor( BOOL bForce = FALSE);
// Primitive draw-ers
void PMDrawRect( nsRect &rect, BOOL fill);
void PMDrawPoly( const nsPoint aPoints[], PRInt32 aNumPoints, PRBool bFilled);
void PMDrawArc( nsRect &rect, PRBool bFilled, PRBool bFull, PRInt32 start=0, PRInt32 end=0);
protected:
~nsRenderingContextOS2();
#if 0 // OS2TODO
/** ---------------------------------------------------
* See documentation in nsIRenderingContextImpl.h
* @update 4/01/00 dwc
*/
virtual PRBool CanTile(nscoord aWidth,nscoord aHeight);
#endif
protected:
nsIDeviceContext *mContext; // device context
nsIPaletteOS2 *mPalette; // palette from the dc
nsDrawingSurfaceOS2 *mSurface; // draw things here

View File

@ -44,7 +44,7 @@ EXTRA_DSO_LDOPTS = $(EXTRA_DSO_LIBS) \
$(NULL)
ifeq ($(MOZ_OS2_TOOLS),VACPP)
EXTRA_DSO_LDOPTS += libuls.lib
EXTRA_DSO_LDOPTS += libuls.$(LIB_SUFFIX) ../libnslocale_s.$(LIB_SUFFIX)
else
EXTRA_DSO_LDOPTS += -llibuni
endif
@ -53,3 +53,4 @@ include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/..

View File

@ -25,10 +25,10 @@
#include "ulsitem.h"
#include "nsDateTimeFormatOS2.h"
#include "nsILocaleOS2.h"
#include "nsIOS2Locale.h"
#include "nsCOMPtr.h"
static NS_DEFINE_IID(kILocaleOS2IID, NS_ILOCALEOS2_IID);
static NS_DEFINE_IID(kILocaleOS2IID, NS_IOS2LOCALE_IID);
static NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
// nsISupports implementation
@ -69,7 +69,7 @@ nsresult nsDateTimeFormatOS2::FormatTMTime( nsILocale *aLocale,
if( !aLocale || !aTime)
return NS_ERROR_NULL_POINTER;
nsCOMPtr <nsILocaleOS2> os2locale;
nsCOMPtr <nsIOS2Locale> os2locale;
nsresult rc = NS_ERROR_FAILURE;
// find a sane locale object
@ -173,3 +173,50 @@ nsresult nsDateTimeFormatOS2::FormatTMTime( nsILocale *aLocale,
return rc;
}
// performs a locale sensitive date formatting operation on the PRTime parameter
nsresult nsDateTimeFormatOS2::FormatPRTime(nsILocale* locale,
const nsDateFormatSelector dateFormatSelector,
const nsTimeFormatSelector timeFormatSelector,
const PRTime prTime,
nsString& stringOut)
{
PRExplodedTime explodedTime;
PR_ExplodeTime(prTime, PR_LocalTimeParameters, &explodedTime);
return FormatPRExplodedTime(locale, dateFormatSelector, timeFormatSelector, &explodedTime, stringOut);
}
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
nsresult nsDateTimeFormatOS2::FormatPRExplodedTime(nsILocale* locale,
const nsDateFormatSelector dateFormatSelector,
const nsTimeFormatSelector timeFormatSelector,
const PRExplodedTime* explodedTime,
nsString& stringOut)
{
struct tm tmTime;
/* be safe and set all members of struct tm to zero
*
* there are other fields in the tm struct that we aren't setting
* (tm_isdst, tm_gmtoff, tm_zone, should we set these?) and since
* tmTime is on the stack, it may be filled with garbage, but
* the garbage may vary. (this may explain why some saw bug #10412, and
* others did not.
*
* when tmTime is passed to strftime() with garbage bad things may happen.
* see bug #10412
*/
nsCRT::memset( &tmTime, 0, sizeof(tmTime) );
tmTime.tm_yday = explodedTime->tm_yday;
tmTime.tm_wday = explodedTime->tm_wday;
tmTime.tm_year = explodedTime->tm_year;
tmTime.tm_year -= 1900;
tmTime.tm_mon = explodedTime->tm_month;
tmTime.tm_mday = explodedTime->tm_mday;
tmTime.tm_hour = explodedTime->tm_hour;
tmTime.tm_min = explodedTime->tm_min;
tmTime.tm_sec = explodedTime->tm_sec;
return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
}

View File

@ -50,6 +50,21 @@ class nsDateTimeFormatOS2 : public nsIDateTimeFormat
const nsTimeFormatSelector aTimeFormatSelector,
const struct tm *aTime,
nsString &aStringOut);
// performs a locale sensitive date formatting operation on the PRTime parameter
NS_IMETHOD FormatPRTime(nsILocale* locale,
const nsDateFormatSelector dateFormatSelector,
const nsTimeFormatSelector timeFormatSelector,
const PRTime prTime,
nsString& stringOut);
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
NS_IMETHOD FormatPRExplodedTime(nsILocale* locale,
const nsDateFormatSelector dateFormatSelector,
const nsTimeFormatSelector timeFormatSelector,
const PRExplodedTime* explodedTime,
nsString& stringOut);
};
#endif

View File

@ -16,7 +16,7 @@
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*
*/
#include "nscore.h"
@ -35,7 +35,7 @@
static NS_DEFINE_IID(kICollationFactoryIID, NS_ICOLLATIONFACTORY_IID);
static NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
static NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
static NS_DEFINE_IID(kILocaleFactoryIID,NS_ILOCALEFACTORY_IID);
//static NS_DEFINE_IID(kILocaleFactoryIID,NS_ILOCALEFACTORY_IID);
static NS_DEFINE_CID(kLocaleFactoryCID, NS_LOCALEFACTORY_CID);
static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID);
@ -82,7 +82,7 @@ nsLocaleDllFactory::nsLocaleDllFactory( const nsCID &aClass)
mClassID = aClass;
}
NS_IMPL_ISUPPORTS(nsLocaleDllFactory,NS_GET_IID(nsIFactory))
NS_IMPL_ISUPPORTS(nsLocaleDllFactory,nsIFactory::GetIID())
nsresult nsLocaleDllFactory::CreateInstance( nsISupports *aOuter,
const nsIID &aIID,
@ -133,13 +133,13 @@ extern "C" NS_EXPORT nsresult NSGetFactory( nsISupports *aServiceMgr,
{
fact = new nsLocaleFactoryOS2;
// XXX this next line looks a bit wrong, but hey...
rc = fact->QueryInterface( kILocaleFactoryIID, (void **) aFactory);
// rc = fact->QueryInterface( kILocaleFactoryIID, (void **) aFactory);
}
else // something sensible
{
fact = new nsLocaleDllFactory( aClass);
rc = fact->QueryInterface( NS_GET_IID(nsIFactory), (void**)aFactory);
rc = fact->QueryInterface( nsIFactory::GetIID(), (void**)aFactory);
}
if( NS_FAILED(rc))

View File

@ -207,10 +207,37 @@ nsLocaleFactoryOS2::CreateInstance(nsISupports* aOuter, REFNSIID aIID,
return ret;
}
nsresult nsLocaleFactoryOS2::QueryInterface(const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *)(nsISupports*)this;
}
else if (aIID.Equals(kIFactoryIID)) {
*aResult = (void *)(nsIFactory*)this;
}
if (*aResult == NULL) {
return NS_NOINTERFACE;
}
NS_ADDREF_THIS(); // Increase reference count for caller
return NS_OK;
}
NS_IMETHODIMP
nsLocaleFactoryOS2::LockFactory(PRBool aBool)
{
return NS_OK;
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsLocaleFactoryOS2, nsIFactory)
NS_IMPL_ADDREF(nsLocaleFactoryOS2);
NS_IMPL_RELEASE(nsLocaleFactoryOS2);

View File

@ -23,11 +23,15 @@
#include <os2.h>
#include "unidef.h"
#include "nsISupports.h"
#include "nscore.h"
#include "nsString.h"
#include "nsILocale.h"
#include "nsLocaleOS2.h"
#include "nsLocaleCID.h"
static NS_DEFINE_IID(kILocaleIID, NS_ILOCALE_IID);
static NS_DEFINE_IID(kILocaleOS2IID, NS_ILOCALEOS2_IID);
static NS_DEFINE_IID(kIOS2LocaleIID, NS_IOS2LOCALE_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
// for now
@ -36,18 +40,18 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
#endif
// nsISupports implementation
NS_IMPL_ADDREF(nsLocaleOS2)
NS_IMPL_RELEASE(nsLocaleOS2)
NS_IMPL_ADDREF(nsOS2Locale)
NS_IMPL_RELEASE(nsOS2Locale)
nsresult nsLocaleOS2::QueryInterface( const nsIID &aIID, void **aInstancePtr)
nsresult nsOS2Locale::QueryInterface( const nsIID &aIID, void **aInstancePtr)
{
if( !aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = nsnull;
if( aIID.Equals( kILocaleOS2IID))
*aInstancePtr = (void*) ((nsILocaleOS2*)this);
if( aIID.Equals( kIOS2LocaleIID))
*aInstancePtr = (void*) ((nsIOS2Locale*)this);
else if( aIID.Equals( kILocaleIID))
*aInstancePtr = (void*) ((nsILocale*)this);
else if( aIID.Equals( kISupportsIID))
@ -61,12 +65,12 @@ nsresult nsLocaleOS2::QueryInterface( const nsIID &aIID, void **aInstancePtr)
}
// ctor-dtor
nsLocaleOS2::nsLocaleOS2() : mLocaleObject(nsnull)
nsOS2Locale::nsOS2Locale() : mLocaleObject(nsnull)
{
NS_INIT_REFCNT();
}
nsLocaleOS2::~nsLocaleOS2()
nsOS2Locale::~nsOS2Locale()
{
if( mLocaleObject)
UniFreeLocaleObject( mLocaleObject);
@ -89,10 +93,10 @@ static int GetLocaleCategory( const nsString *aCat)
return category;
}
// nsILocaleOS2
// nsIOS2Locale
// Init a complex locale - categories should be magic nsLocale words
nsresult nsLocaleOS2::Init( nsString **aCatList,
nsresult nsOS2Locale::Init( nsString **aCatList,
nsString **aValList,
PRUint8 aLength)
{
@ -166,7 +170,7 @@ nsresult nsLocaleOS2::Init( nsString **aCatList,
}
// Init a locale object from a xx-XX style name
nsresult nsLocaleOS2::Init( const nsString &aLocaleName)
nsresult nsOS2Locale::Init( const nsString &aLocaleName)
{
char szLocale[7] = { 0 };
@ -194,7 +198,7 @@ nsresult nsLocaleOS2::Init( const nsString &aLocaleName)
return rc;
}
nsresult nsLocaleOS2::Init( char *pszLocale)
nsresult nsOS2Locale::Init( char *pszLocale)
{
nsresult nr = NS_ERROR_FAILURE;
@ -208,7 +212,7 @@ nsresult nsLocaleOS2::Init( char *pszLocale)
}
// Get the OS/2 locale object
nsresult nsLocaleOS2::GetLocaleObject( LocaleObject *aLocaleObject)
nsresult nsOS2Locale::GetLocaleObject( LocaleObject *aLocaleObject)
{
if( !aLocaleObject)
return NS_ERROR_NULL_POINTER;
@ -218,7 +222,7 @@ nsresult nsLocaleOS2::GetLocaleObject( LocaleObject *aLocaleObject)
}
// nsILocale
nsresult nsLocaleOS2::GetCategory( const nsString *aCat, nsString *aLocale)
nsresult nsOS2Locale::GetCategory( const nsString *aCat, nsString *aLocale)
{
if( !aCat || !aLocale)
return NS_ERROR_NULL_POINTER;
@ -249,3 +253,16 @@ nsSystemLocale::nsSystemLocale()
{
Init( ""); // create locale based on value of LANG and friends
}
// XXXX STUBS
NS_IMETHODIMP
nsOS2Locale::GetPlatformLocale(const nsString* locale,char* os2Locale, size_t length)
{
return NS_OK;
}
NS_IMETHODIMP
nsOS2Locale::GetXPLocale(const char* os2Locale, nsString* locale)
{
return NS_OK;
}

View File

@ -22,14 +22,16 @@
#ifndef _nslocaleos2_h_
#define _nslocaleos2_h_
#include "nsILocale.h"
#include "nsILocaleOS2.h"
#include "nsISupports.h"
#include "nscore.h"
#include "nsString.h"
#include "nsIOS2Locale.h"
class nsLocaleOS2 : public nsILocale, public nsILocaleOS2
class nsOS2Locale : public nsIOS2Locale
{
public:
nsLocaleOS2();
virtual ~nsLocaleOS2();
nsOS2Locale();
virtual ~nsOS2Locale();
// nsISupports
NS_DECL_ISUPPORTS
@ -37,7 +39,7 @@ class nsLocaleOS2 : public nsILocale, public nsILocaleOS2
// nsILocale
NS_IMETHOD GetCategory( const nsString *aCat, nsString *aLocale);
// nsILocaleOS2
// nsIOS2Locale
// Init a complex locale - categories should be magic nsLocale words
NS_IMETHOD Init( nsString **aCatList,
nsString **aValList,
@ -49,13 +51,17 @@ class nsLocaleOS2 : public nsILocale, public nsILocaleOS2
// Get the OS/2 locale object
NS_IMETHOD GetLocaleObject( LocaleObject *aLocaleObject);
NS_IMETHOD GetPlatformLocale(const nsString* locale,char* os2Locale,
size_t length);
NS_IMETHOD GetXPLocale(const char* os2Locale, nsString* locale);
protected:
LocaleObject mLocaleObject;
NS_IMETHOD Init( char *pszLocale);
};
class nsSystemLocale : public nsLocaleOS2
class nsSystemLocale : public nsOS2Locale
{
public:
nsSystemLocale();

View File

@ -28,6 +28,7 @@
* Date Modified by Description of modification
* 03/23/2000 IBM Corp. Fix missing title bars on profile wizard windows.
* 04/11/2000 IBM Corp. Remove assertion.
* 05/10/2000 IBM Corp. Correct initial position of frame w/titlebar
*/
// Frame window - produced when NS_WINDOW_CID is required.
@ -96,9 +97,34 @@ void nsFrameWindow::RealDoCreate( HWND hwndP, nsWindow *aParent,
NS_ASSERTION( hwndFrame, "Couldn't create frame");
// Frames have a minimum height based on the pieces they are created with,
// such as titlebar, menubar, frame borders, etc. We need this minimum
// height so we can correctly set the frame position (coordinate flipping).
nsRect frameRect = aRect;
long minheight;
if ( fcd.flCreateFlags & FCF_SIZEBORDER) {
minheight = 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER);
}
else if ( fcd.flCreateFlags & FCF_DLGBORDER) {
minheight = 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYDLGFRAME);
}
else {
minheight = 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER);
}
if ( fcd.flCreateFlags & FCF_TITLEBAR) {
minheight += WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR);
}
if ( fcd.flCreateFlags & FCF_MENU) {
minheight += WinQuerySysValue( HWND_DESKTOP, SV_CYMENU);
}
if ( frameRect.height < minheight) {
frameRect.height = minheight;
}
// Now create the client as a child of us, triggers resize and sets
// up the client size (with any luck...)
nsCanvas::RealDoCreate( hwndFrame, nsnull, aRect, aHandleEventFunction,
nsCanvas::RealDoCreate( hwndFrame, nsnull, frameRect, aHandleEventFunction,
aContext, aAppShell, aInitData, hwndO);
// Subclass frame

View File

@ -16,25 +16,31 @@
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
*
* Contributor(s):
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 04/20/2000 IBM Corp. Make more like Windows.
*
*/
#ifndef _nsLookAndFeel_h
#define _nsLookAndFeel_h
#ifndef __nsLookAndFeel
#define __nsLookAndFeel
#include "nsILookAndFeel.h"
#include "nsCOMPtr.h"
class nsLookAndFeel: public nsILookAndFeel
{
public:
nsLookAndFeel();
class nsLookAndFeel: public nsILookAndFeel {
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
NS_IMETHOD GetColor( const nsColorID aID, nscolor &aColor);
NS_IMETHOD GetMetric( const nsMetricID aID, PRInt32 &aMetric);
NS_IMETHOD GetMetric( const nsMetricFloatID aID, float &aMetric);
NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor);
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric);
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric);
#ifdef NS_DEBUG
// This method returns the actual (or nearest estimate)

View File

@ -1932,10 +1932,21 @@ nsresult nsWindow::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchron
nsresult rv = NS_OK;
if( mWnd) {
HRGN nativeRegion;
rv = aRegion->GetNativeRegion((void *&)nativeRegion);
rv = aRegion->GetNativeRegion( (void *&)nativeRegion);
if( nativeRegion) {
if( NS_SUCCEEDED(rv)) {
WinInvalidateRegion(mWnd, nativeRegion, TRUE);
RECTL rcl;
LONG height;
HPS hps = WinGetScreenPS( HWND_DESKTOP);
LONG lComplexity = GpiQueryRegionBox( hps, nativeRegion, &rcl);
WinReleasePS( hps);
height = rcl.yTop - rcl.yBottom;
rcl.yTop = GetClientHeight() - rcl.yBottom;
rcl.yBottom = rcl.yTop - height;
WinInvalidateRect( mWnd, &rcl, FALSE);
// WinInvalidateRegion( mWnd, nativeRegion, TRUE);
#if 0
if( PR_TRUE == aIsSynchronous)
Update();

View File

@ -53,6 +53,7 @@
#ifdef XP_OS2_VACPP
#include <direct.h>
#include "dirent.h"
#define F_OK 0
#define X_OK 1
#define W_OK 2
@ -341,13 +342,13 @@ nsLocalFile::Create(PRUint32 type, PRUint32 attributes)
if (stricmp(tail, leaf) || tail != nsnull) {
// Absolute path
if (mPath[2] == '\\' && mPath[1] == ':') {
if (mPath.CharAt(2) == '\\' && mPath.CharAt(1) == ':') {
++tail;
tail = strchr(tail, '\\');
}
// LAN path
if (mPath[0] == '\\' && mPath[1] == '\\') {
if (mPath.CharAt(0) == '\\' && mPath.CharAt(1) == '\\') {
tail += 2;
tail = strchr(tail, '\\');
}
@ -356,7 +357,7 @@ nsLocalFile::Create(PRUint32 type, PRUint32 attributes)
size_t idx = len - strlen(tail);
while (stricmp(segment, mPath)) {
memcpy(segment, mPath, idx);
memcpy(segment, (char*)mPath, idx);
if (access(segment, F_OK) != 0)
mkdir(segment, 0);
@ -480,7 +481,7 @@ NS_IMETHODIMP
nsLocalFile::GetPath(char **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = (char*)nsAllocator::Clone(mPath, strlen(mPath) + 1);
*_retval = (char*)nsAllocator::Clone((char*)mPath, strlen(mPath) + 1);
return NS_OK;
}
@ -633,7 +634,7 @@ nsLocalFile::Delete(PRBool recursive)
iterator->HasMoreElements(&more);
}
}
rmdir(filePath); // todo: save return value?
rmdir((char*)filePath); // todo: save return value?
}
else
{
@ -662,9 +663,9 @@ nsLocalFile::SetLastModificationDate(PRInt64 aLastModificationDate)
struct utimbuf ut;
ut.actime = mStatCache.st_atime;
LL_L2UI(ut.modtime, aLastModificationDate);
result = utime((const char*)mPath, &ut);
result = utime((char*)mPath, &ut);
} else {
result = utime((const char*)mPath, NULL);
result = utime((char*)mPath, NULL);
}
SetNoStatCache();
return NSRESULT_FOR_RETURN(result);
@ -769,7 +770,7 @@ nsLocalFile::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
NS_ENSURE_ARG_POINTER(aDiskSpaceAvailable);
CHECK_mPath();
ULONG ulDriveNo = toupper(mPath[0]) + 1 - 'A';
ULONG ulDriveNo = toupper(mPath.CharAt(0)) + 1 - 'A';
FSALLOCATE fsAllocate = { 0 };
APIRET rv = DosQueryFSInfo(ulDriveNo, FSIL_ALLOC,
&fsAllocate, sizeof(fsAllocate));
@ -984,7 +985,7 @@ nsLocalFile::GetTarget(char **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
VALIDATE_STAT_CACHE();
*_retval = (char*)nsAllocator::Clone(mPath, strlen(mPath) + 1);
*_retval = (char*)nsAllocator::Clone((char*)mPath, strlen(mPath) + 1);
return NS_OK;
}

View File

@ -48,6 +48,10 @@
#include <io.h>
#include <errno.h>
#ifdef XP_OS2_VACPP
#define ENOTDIR EBADPOS
#endif
#define NSRESULT_FOR_RETURN(ret) (!(ret) ? NS_OK : NSRESULT_FOR_ERRNO())
inline nsresult

View File

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/11/2000 IBM Corp. Created for OS/2 VisualAge build.
*/
#include "nsUserInfo.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsXPIDLString.h"
nsUserInfo::nsUserInfo()
{
NS_INIT_REFCNT();
}
nsUserInfo::~nsUserInfo()
{
}
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo);
NS_IMETHODIMP
nsUserInfo::GetUsername(char **aUsername)
{
*aUsername = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetFullname(PRUnichar **aFullname)
{
*aFullname = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
*aDomain = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
{
*aEmailAddress = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
* described herein are Copyright (c) International Business Machines Corporation, 2000.
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 05/11/2000 IBM Corp. Created for OS/2 VisualAge build.
*/
#include "nsUserInfo.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsXPIDLString.h"
nsUserInfo::nsUserInfo()
{
NS_INIT_REFCNT();
}
nsUserInfo::~nsUserInfo()
{
}
NS_IMPL_ISUPPORTS1(nsUserInfo,nsIUserInfo);
NS_IMETHODIMP
nsUserInfo::GetUsername(char **aUsername)
{
*aUsername = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetFullname(PRUnichar **aFullname)
{
*aFullname = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
*aDomain = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
{
*aEmailAddress = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}