diff --git a/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp b/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp index dbe19b17817..4b32d886f9e 100644 --- a/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp +++ b/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp @@ -28,6 +28,9 @@ #include #include +/* Should be defined in the Photon headers somewhere */ +extern void PdReleaseDirectContext( PdDirectContext_t *DirectContext ); + /* The Transparency Mask of the last image Draw'd in nsRenderingContextPh */ /* This is needed for locking and unlocking */ extern void *Mask; @@ -95,7 +98,7 @@ nsDrawingSurfacePh :: ~nsDrawingSurfacePh() // PgSetGC(mGC); // PgSetRegion(mGC->rid); mDrawContext->gc=0; - PdReleaseDirectContext((PdDirectContext_t *)mDrawContext); /* this function has an error! */ + PdReleaseDirectContext((PdDirectContext_t *)mDrawContext); /* this function has an error! */ mDrawContext=0; } // free(mMC); diff --git a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp index 99aa34a1793..14d0a101232 100644 --- a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp +++ b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp @@ -1489,7 +1489,7 @@ NS_IMETHODIMP nsRenderingContextPh :: GetWidth(const PRUnichar *aString, { PhRect_t extent; - if (PfExtentWideText(&extent, NULL, mPhotonFontName, (wchar_t *) aString, (aLength*2))) + if (PfExtentWideText(&extent, NULL, mPhotonFontName, (const uint16_t *) aString, (aLength*2))) { aWidth = (int) ((extent.lr.x - extent.ul.x + 1) * mP2T); PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::GetWidth6 aWidth=<%d>mPhotonFontName=<%s>\n", aWidth, mPhotonFontName)); diff --git a/mozilla/gfx/src/photon/nsScreenManagerPh.cpp b/mozilla/gfx/src/photon/nsScreenManagerPh.cpp new file mode 100644 index 00000000000..b68b654a4ce --- /dev/null +++ b/mozilla/gfx/src/photon/nsScreenManagerPh.cpp @@ -0,0 +1,117 @@ +/* -*- 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nsScreenManagerPh.h" +#include "nsScreenPh.h" + +#include "nsPhGfxLog.h" + +nsScreenManagerPh :: nsScreenManagerPh ( ) +{ + NS_INIT_REFCNT(); + + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenManagerPh::nsScreenManagerPh Constructor called this=<%p>\n", this)); + + // nothing else to do. I guess we could cache a bunch of information + // here, but we want to ask the device at runtime in case anything + // has changed. +} + + +nsScreenManagerPh :: ~nsScreenManagerPh() +{ + // nothing to see here. + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenManagerPh::~nsScreenManagerPh Destructor called this=<%p>\n", this)); + +} + + +// addref, release, QI +NS_IMPL_ISUPPORTS(nsScreenManagerPh, NS_GET_IID(nsIScreenManager)) + + +// +// CreateNewScreenObject +// +// Utility routine. Creates a new screen object from the given device handle +// +// NOTE: For this "single-monitor" impl, we just always return the cached primary +// screen. This should change when a multi-monitor impl is done. +// +nsIScreen* +nsScreenManagerPh :: CreateNewScreenObject ( ) +{ + nsIScreen* retval = nsnull; + if ( !mCachedMainScreen ) + mCachedMainScreen = new nsScreenPh ( ); + NS_IF_ADDREF(retval = mCachedMainScreen.get()); + + return retval; +} + + +// +// ScreenForRect +// +// Returns the screen that contains the rectangle. If the rect overlaps +// multiple screens, it picks the screen with the greatest area of intersection. +// +// The coordinates are in pixels (not twips) and in screen coordinates. +// +NS_IMETHODIMP +nsScreenManagerPh :: ScreenForRect ( PRInt32 /*inLeft*/, PRInt32 /*inTop*/, PRInt32 /*inWidth*/, + PRInt32 /*inHeight*/, nsIScreen **outScreen ) +{ + GetPrimaryScreen ( outScreen ); + return NS_OK; + +} // ScreenForRect + + +// +// GetPrimaryScreen +// +// The screen with the menubar/taskbar. This shouldn't be needed very +// often. +// +NS_IMETHODIMP +nsScreenManagerPh :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen) +{ + *aPrimaryScreen = CreateNewScreenObject(); // addrefs + return NS_OK; + +} // GetPrimaryScreen + + +// +// GetNumberOfScreens +// +// Returns how many physical screens are available. +// +NS_IMETHODIMP +nsScreenManagerPh :: GetNumberOfScreens(PRUint32 *aNumberOfScreens) +{ + *aNumberOfScreens = 1; + return NS_OK; + +} // GetNumberOfScreens + diff --git a/mozilla/gfx/src/photon/nsScreenManagerPh.h b/mozilla/gfx/src/photon/nsScreenManagerPh.h new file mode 100644 index 00000000000..7eab7c8ebd7 --- /dev/null +++ b/mozilla/gfx/src/photon/nsScreenManagerPh.h @@ -0,0 +1,50 @@ +/* -*- 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#ifndef nsScreenManagerPh_h___ +#define nsScreenManagerPh_h___ + +#include "nsIScreenManager.h" +#include "nsIScreen.h" +#include "nsCOMPtr.h" + +//------------------------------------------------------------------------ + +class nsScreenManagerPh : public nsIScreenManager +{ +public: + nsScreenManagerPh ( ); + virtual ~nsScreenManagerPh(); + + NS_DECL_ISUPPORTS + NS_DECL_NSISCREENMANAGER + +private: + + nsIScreen* CreateNewScreenObject ( ) ; + + // cache the primary screen object to avoid memory allocation every time + nsCOMPtr mCachedMainScreen; + +}; + +#endif // nsScreenManagerPh_h___ diff --git a/mozilla/gfx/src/photon/nsScreenPh.cpp b/mozilla/gfx/src/photon/nsScreenPh.cpp new file mode 100644 index 00000000000..55161076b78 --- /dev/null +++ b/mozilla/gfx/src/photon/nsScreenPh.cpp @@ -0,0 +1,162 @@ +/* -*- 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#include "nsScreenPh.h" + +#include +#include "nsPhGfxLog.h" + +nsScreenPh :: nsScreenPh ( ) +{ + nsresult res = NS_ERROR_FAILURE; + PhSysInfo_t SysInfo; + PhRect_t rect; + char *p = NULL; + int inp_grp = 0; + PhRid_t rid; + PhRegion_t region; + + NS_INIT_REFCNT(); + + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenPh::nsScreenPh Constructor called this=<%p>\n", this)); + + + // nothing else to do. I guess we could cache a bunch of information + // here, but we want to ask the device at runtime in case anything + // has changed. + + /* Initialize the data members */ + /* Get the Screen Size and Depth*/ + p = getenv("PHIG"); + if (p) + { + inp_grp = atoi(p); + + PhQueryRids( 0, 0, inp_grp, Ph_INPUTGROUP_REGION, 0, 0, 0, &rid, 1 ); + PhRegionQuery( rid, ®ion, &rect, NULL, 0 ); + inp_grp = region.input_group; + PhWindowQueryVisible( Ph_QUERY_INPUT_GROUP | Ph_QUERY_EXACT, 0, inp_grp, &rect ); + mWidth = rect.lr.x - rect.ul.x + 1; + mHeight = rect.lr.y - rect.ul.y + 1; + + /* Get the System Info for the RID */ + if (!PhQuerySystemInfo(rid, NULL, &SysInfo)) + { + PR_LOG(PhGfxLog, PR_LOG_ERROR,("nsScreenPh::nsScreenPh with aWidget: Error getting SystemInfo\n")); + } + else + { + /* Make sure the "color_bits" field is valid */ + if (SysInfo.gfx.valid_fields & Ph_GFX_COLOR_BITS) + { + mPixelDepth = SysInfo.gfx.color_bits; + } + } + } + else + { + printf("nsScreenPh::nsScreenPh The PHIG environment variable must be set, try setting it to 1\n"); + } +} + +nsScreenPh :: ~nsScreenPh() +{ + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenPh::~nsScreenPh Destructor called this=<%p>\n", this)); + + // nothing to see here. +} + + +// addref, release, QI +NS_IMPL_ISUPPORTS(nsScreenPh, NS_GET_IID(nsIScreen)) + + +NS_IMETHODIMP +nsScreenPh :: GetWidth(PRInt32 *aWidth) +{ + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenPh::GetWidth Constructor called this=<%p>\n", this)); + + *aWidth = mWidth; + return NS_OK; + +} // GetWidth + + +NS_IMETHODIMP +nsScreenPh :: GetHeight(PRInt32 *aHeight) +{ + *aHeight = mHeight; + return NS_OK; + +} // GetHeight + + +NS_IMETHODIMP +nsScreenPh :: GetPixelDepth(PRInt32 *aPixelDepth) +{ + *aPixelDepth = mPixelDepth; + return NS_OK; + +} // GetPixelDepth + + +NS_IMETHODIMP +nsScreenPh :: GetColorDepth(PRInt32 *aColorDepth) +{ + return GetPixelDepth ( aColorDepth ); + +} // GetColorDepth + + +NS_IMETHODIMP +nsScreenPh :: GetAvailWidth(PRInt32 *aAvailWidth) +{ + return GetWidth(aAvailWidth); + +} // GetAvailWidth + + +NS_IMETHODIMP +nsScreenPh :: GetAvailHeight(PRInt32 *aAvailHeight) +{ + return GetHeight(aAvailHeight); + +} // GetAvailHeight + + +NS_IMETHODIMP +nsScreenPh :: GetAvailLeft(PRInt32 *aAvailLeft) +{ + *aAvailLeft = 0; + return NS_OK; + +} // GetAvailLeft + + +NS_IMETHODIMP +nsScreenPh :: GetAvailTop(PRInt32 *aAvailTop) +{ + *aAvailTop = 0; + return NS_OK; + +} // GetAvailTop + diff --git a/mozilla/gfx/src/photon/nsScreenPh.h b/mozilla/gfx/src/photon/nsScreenPh.h new file mode 100644 index 00000000000..20a6c40b8bb --- /dev/null +++ b/mozilla/gfx/src/photon/nsScreenPh.h @@ -0,0 +1,45 @@ +/* -*- 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.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2000 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#ifndef nsScreenPh_h___ +#define nsScreenPh_h___ + +#include "nsIScreen.h" + +//------------------------------------------------------------------------ + +class nsScreenPh : public nsIScreen +{ +public: + nsScreenPh ( ); + virtual ~nsScreenPh(); + + NS_DECL_ISUPPORTS + NS_DECL_NSISCREEN + +private: + PRInt32 mWidth; + PRInt32 mHeight; + PRInt32 mPixelDepth; +}; + +#endif // nsScreenPh_h___