mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
[OS/2] Remove non-cairo OS2 gfx code from the tree. b=389729 r=mozilla@Weilbacher.org
This commit is contained in:
parent
48b32c77cf
commit
702ba6d4be
@ -107,9 +107,4 @@ CXXFLAGS += -I$(topsrcdir)/gfx/src/mac
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT), os2)
|
||||
# needed for nsDrawingSurfaceOS2.h
|
||||
CXXFLAGS += -I$(topsrcdir)/gfx/src/os2
|
||||
endif
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
@ -81,7 +81,7 @@ else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
DIRS += mac
|
||||
endif
|
||||
ifneq (,$(filter windows beos os2 mac,$(MOZ_WIDGET_TOOLKIT)))
|
||||
ifneq (,$(filter windows beos mac,$(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS += $(MOZ_WIDGET_TOOLKIT)
|
||||
endif
|
||||
endif
|
||||
@ -112,19 +112,6 @@ CPPSRCS += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
CPPSRCS += \
|
||||
os2/nsOS2Uni.cpp \
|
||||
os2/nsPaletteOS2.cpp \
|
||||
os2/nsPrintOS2.cpp \
|
||||
$(NULL)
|
||||
EXPORTS += \
|
||||
os2/nsOS2Uni.h \
|
||||
os2/nsPaletteOS2.h \
|
||||
os2/nsPrintOS2.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(DEPTH)/modules/libutil/src/$(LIB_PREFIX)mozutil_s.$(LIB_SUFFIX) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
|
@ -1,111 +0,0 @@
|
||||
#
|
||||
# ***** 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 OS/2 libraries.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# John Fairhurst, <john_fairhurst@iname.com>.
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gfx
|
||||
LIBRARY_NAME = gfx_os2
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGfxOS2Module
|
||||
GRE_MODULE = 1
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
PACKAGE_FILE = gfxos2.pkg
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
widget \
|
||||
view \
|
||||
util \
|
||||
pref \
|
||||
uconv \
|
||||
locale \
|
||||
unicharutil \
|
||||
imglib2 \
|
||||
$(NULL)
|
||||
|
||||
# code that we share with Win32
|
||||
SHARED_LCPPSRCS = nsUnicodeRange.cpp
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceContextOS2.cpp \
|
||||
nsDrawingSurfaceOS2.cpp \
|
||||
nsRenderingContextOS2.cpp \
|
||||
nsFontMetricsOS2.cpp \
|
||||
nsImageOS2.cpp \
|
||||
nsRegionOS2.cpp \
|
||||
nsGfxFactoryOS2.cpp \
|
||||
nsGfxDefs.cpp \
|
||||
$(SHARED_LCPPSRCS) \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsIRenderingContextOS2.h \
|
||||
nsDrawingSurfaceOS2.h \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LIBS = gkgfx mozutil_s gfxshared_s
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
GARBAGE += $(SHARED_LCPPSRCS) $(wildcard *.$(OBJ_SUFFIX))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../shared \
|
||||
-I$(srcdir)/../windows \
|
||||
-I$(srcdir)/../../../widget/src/os2 \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -DUSE_OS2_TOOLKIT_HEADERS
|
||||
|
||||
export:: $(addprefix $(srcdir)/../windows/,$(SHARED_LCPPSRCS))
|
||||
$(INSTALL) $^ .
|
||||
|
@ -1,6 +0,0 @@
|
||||
[gecko]
|
||||
#if SHARED_LIBRARY
|
||||
dist/bin/components/@SHARED_LIBRARY@
|
||||
#else
|
||||
!staticcomp @LIBRARY@ @MODULE_NAME@
|
||||
#endif
|
@ -1,870 +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 the Mozilla OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Henry Sobotka <sobotka@axess.com> 2OOO/O2 update
|
||||
* IBM Corp.
|
||||
*
|
||||
* 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 "nsDeviceContextOS2.h"
|
||||
#include "nsRenderingContextOS2.h"
|
||||
#include "nsDeviceContextSpecOS2.h"
|
||||
#include "nsPrintOS2.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIScreen.h"
|
||||
|
||||
#include "nsHashTable.h" // For CreateFontAliasTable()
|
||||
|
||||
#include "nsGfxDefs.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsOS2Uni.h"
|
||||
#include "nsPaletteOS2.h"
|
||||
|
||||
#define NOT_SETUP 0x33
|
||||
static PRBool gIsWarp4 = NOT_SETUP;
|
||||
|
||||
PRUint32 nsDeviceContextOS2::sNumberOfScreens = 0;
|
||||
nscoord nsDeviceContextOS2::mDpi = 120;
|
||||
|
||||
|
||||
nsDeviceContextOS2 :: nsDeviceContextOS2()
|
||||
: DeviceContextImpl()
|
||||
{
|
||||
mSurface = NULL;
|
||||
mIsPaletteDevice = PR_FALSE;
|
||||
mPrintDC = NULL;
|
||||
mWidth = -1;
|
||||
mHeight = -1;
|
||||
mSpec = nsnull;
|
||||
mCachedClientRect = PR_FALSE;
|
||||
mCachedFullRect = PR_FALSE;
|
||||
mSupportsRasterFonts = PR_FALSE;
|
||||
mPrintingStarted = PR_FALSE;
|
||||
#ifdef XP_OS2
|
||||
mPrintState = nsPrintState_ePreBeginDoc;
|
||||
#endif
|
||||
|
||||
// The first time in we initialize gIsWarp4 flag
|
||||
if (NOT_SETUP == gIsWarp4) {
|
||||
unsigned long ulValues[2];
|
||||
DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
|
||||
ulValues, sizeof(ulValues));
|
||||
gIsWarp4 = (ulValues[0] >= 20) && (ulValues[1] >= 40);
|
||||
}
|
||||
}
|
||||
|
||||
nsDeviceContextOS2::~nsDeviceContextOS2()
|
||||
{
|
||||
if(mPrintDC)
|
||||
{
|
||||
GFX (::GpiDestroyPS (mPrintPS), FALSE);
|
||||
::DevCloseDC(mPrintDC);
|
||||
} else {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefs->UnregisterCallback("layout.css.dpi",
|
||||
prefChanged, (void *)this);
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(mSpec);
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::Init( nsNativeWidget aWidget)
|
||||
{
|
||||
mWidget = aWidget;
|
||||
|
||||
CommonInit(::WinOpenWindowDC((HWND)aWidget));
|
||||
|
||||
static int initialized = 0;
|
||||
PRInt32 prefVal = -1;
|
||||
if (!initialized) {
|
||||
initialized = 1;
|
||||
|
||||
// Set prefVal the value of the preference
|
||||
// "layout.css.dpi"
|
||||
// or -1 if we can't get it.
|
||||
// If it's negative, we pretend it's not set.
|
||||
// If it's 0, it means force use of the operating system's logical
|
||||
// resolution.
|
||||
// If it's positive, we use it as the logical resolution
|
||||
nsresult res;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &res));
|
||||
if (NS_SUCCEEDED(res) && prefs) {
|
||||
res = prefs->GetIntPref("layout.css.dpi", &prefVal);
|
||||
if (NS_FAILED(res)) {
|
||||
prefVal = -1;
|
||||
}
|
||||
prefs->RegisterCallback("layout.css.dpi", prefChanged,
|
||||
(void *)this);
|
||||
}
|
||||
|
||||
SetDPI(prefVal);
|
||||
} else {
|
||||
SetDPI(mDpi); // to setup p2t and t2p
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This version of Init() is called when creating a print DC
|
||||
nsresult nsDeviceContextOS2::Init( nsNativeDeviceContext aContext,
|
||||
nsIDeviceContext *aOrigContext)
|
||||
{
|
||||
float origscale, newscale;
|
||||
float t2d, a2d;
|
||||
|
||||
mPrintDC = (HDC)aContext;
|
||||
|
||||
NS_ASSERTION( mPrintDC, "!ERROR! - Received empty DC for printer");
|
||||
|
||||
#ifdef XP_OS2
|
||||
// Create a print PS now. This is necessary 'cos we need it from
|
||||
// odd places to do font-y things, where the only common reference
|
||||
// point is this DC. We can't just create a new PS because only one
|
||||
// PS can be associated with a given DC, and we can't get that PS from
|
||||
// the DC (really?). And it would be slow :-)
|
||||
SIZEL sizel = { 0 , 0 };
|
||||
mPrintPS = GFX (::GpiCreatePS ( 0/*hab*/, mPrintDC, &sizel,
|
||||
PU_PELS | GPIT_MICRO | GPIA_ASSOC), GPI_ERROR);
|
||||
#endif
|
||||
|
||||
CommonInit( mPrintDC);
|
||||
|
||||
long dpi;
|
||||
GFX (::DevQueryCaps(mPrintDC, CAPS_VERTICAL_FONT_RES, 1, &dpi), FALSE);
|
||||
|
||||
mPixelsToTwips = ((float)NSIntPointsToTwips(72)) / ((float)dpi);
|
||||
mTwipsToPixels = 1.0 / mPixelsToTwips;
|
||||
|
||||
newscale = TwipsToDevUnits();
|
||||
// On OS/2, origscale can be different based on the video resolution.
|
||||
// On 640x480, it's 1/15, on everything else it is 1/12.
|
||||
// For consistent printing, 1/15 is the correct value to use.
|
||||
// It is the closest to 4.x and to Windows.
|
||||
// origscale = aOrigContext->TwipsToDevUnits();
|
||||
origscale = 1.0/15.0;
|
||||
|
||||
mCPixelScale = newscale / origscale;
|
||||
|
||||
t2d = aOrigContext->TwipsToDevUnits();
|
||||
a2d = aOrigContext->AppUnitsToDevUnits();
|
||||
|
||||
mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels;
|
||||
mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;
|
||||
|
||||
#ifdef XP_OS2
|
||||
HCINFO hcinfo;
|
||||
PrnQueryHardcopyCaps( mPrintDC, &hcinfo);
|
||||
mWidth = hcinfo.xPels;
|
||||
mHeight = hcinfo.yPels;
|
||||
// XXX hsb says there are margin problems, must be from here...
|
||||
#ifdef DEBUG
|
||||
printf( "Got surface of size %d x %d pixels (%d Kb)\n", mWidth, mHeight, mWidth * mHeight * mDepth / 8 / 1024);
|
||||
printf( "mCPixelScale = %f\n", mCPixelScale);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDeviceContextOS2 :: CommonInit(HDC aDC)
|
||||
{
|
||||
LONG alArray[CAPS_DEVICE_POLYSET_POINTS];
|
||||
|
||||
GFX (::DevQueryCaps(aDC, CAPS_FAMILY, CAPS_DEVICE_POLYSET_POINTS, alArray), FALSE);
|
||||
|
||||
mDepth = alArray[CAPS_COLOR_BITCOUNT];
|
||||
mIsPaletteDevice = ((alArray[CAPS_ADDITIONAL_GRAPHICS] & CAPS_PALETTE_MANAGER) == CAPS_PALETTE_MANAGER);
|
||||
|
||||
mWidth = alArray[CAPS_WIDTH];
|
||||
mHeight = alArray[CAPS_HEIGHT];
|
||||
|
||||
if (alArray[CAPS_TECHNOLOGY] == CAPS_TECH_RASTER_DISPLAY)
|
||||
{
|
||||
// init the screen manager and compute our client rect based on the
|
||||
// screen objects. We'll save the result
|
||||
nsresult ignore;
|
||||
mScreenManager = do_GetService("@mozilla.org/gfx/screenmanager;1", &ignore);
|
||||
if ( !sNumberOfScreens )
|
||||
mScreenManager->GetNumberOfScreens(&sNumberOfScreens);
|
||||
mSupportsRasterFonts = !!(alArray[CAPS_RASTER_CAPS] & CAPS_RASTER_FONTS);
|
||||
} // if this dc is not a print device
|
||||
|
||||
DeviceContextImpl::CommonInit();
|
||||
}
|
||||
|
||||
void
|
||||
nsDeviceContextOS2 :: ComputeClientRectUsingScreen ( nsRect* outRect )
|
||||
{
|
||||
if ( !mCachedClientRect ) {
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
FindScreen ( getter_AddRefs(screen) );
|
||||
if ( screen ) {
|
||||
PRInt32 x, y, width, height;
|
||||
screen->GetAvailRect ( &x, &y, &width, &height );
|
||||
|
||||
// convert to device units
|
||||
outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
|
||||
outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
|
||||
outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
|
||||
outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);
|
||||
|
||||
mCachedClientRect = PR_TRUE;
|
||||
mClientRect = *outRect;
|
||||
}
|
||||
}
|
||||
else
|
||||
*outRect = mClientRect;
|
||||
|
||||
} // ComputeClientRectUsingScreen
|
||||
|
||||
|
||||
void
|
||||
nsDeviceContextOS2 :: ComputeFullAreaUsingScreen ( nsRect* outRect )
|
||||
{
|
||||
if ( !mCachedFullRect ) {
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
FindScreen ( getter_AddRefs(screen) );
|
||||
if ( screen ) {
|
||||
PRInt32 x, y, width, height;
|
||||
screen->GetRect ( &x, &y, &width, &height );
|
||||
|
||||
// convert to device units
|
||||
outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
|
||||
outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
|
||||
outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
|
||||
outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mCachedFullRect = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
outRect->y = 0;
|
||||
outRect->x = 0;
|
||||
outRect->width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
|
||||
outRect->height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
|
||||
}
|
||||
|
||||
} // ComputeFullRectUsingScreen
|
||||
|
||||
|
||||
//
|
||||
// FindScreen
|
||||
//
|
||||
// Determines which screen intersects the largest area of the given surface.
|
||||
//
|
||||
void
|
||||
nsDeviceContextOS2 :: FindScreen ( nsIScreen** outScreen )
|
||||
{
|
||||
// optimize for the case where we only have one monitor.
|
||||
static nsCOMPtr<nsIScreen> sPrimaryScreen;
|
||||
if ( !sPrimaryScreen && mScreenManager )
|
||||
mScreenManager->GetPrimaryScreen ( getter_AddRefs(sPrimaryScreen) );
|
||||
NS_IF_ADDREF(*outScreen = sPrimaryScreen.get());
|
||||
return;
|
||||
} // FindScreen
|
||||
|
||||
/* OS2TODO - NOT PORTED */
|
||||
// Create a rendering context against our hdc for a printer
|
||||
nsresult nsDeviceContextOS2::CreateRenderingContext( nsIRenderingContext *&aContext)
|
||||
{
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
// Defer to Alt when there is one
|
||||
if (mAltDC && ((mUseAltDC & kUseAltDCFor_CREATERC_PAINT) || (mUseAltDC & kUseAltDCFor_CREATERC_REFLOW))) {
|
||||
return mAltDC->CreateRenderingContext(aContext);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSERTION( mPrintDC, "CreateRenderingContext for non-print DC");
|
||||
|
||||
nsIRenderingContext *pContext = new nsRenderingContextOS2;
|
||||
if (!pContext)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(pContext);
|
||||
|
||||
nsPrintSurface *surf = new nsPrintSurface;
|
||||
if (!surf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
surf->Init( mPrintPS, mWidth, mHeight, 0);
|
||||
|
||||
nsresult rc = pContext->Init(this, surf);
|
||||
|
||||
if( NS_OK != rc)
|
||||
{
|
||||
delete surf;
|
||||
NS_IF_RELEASE(pContext);
|
||||
}
|
||||
|
||||
aContext = pContext;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2 :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
|
||||
{
|
||||
if (nsnull == mPrintDC)
|
||||
aSupportsWidgets = PR_TRUE;
|
||||
else
|
||||
aSupportsWidgets = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nscolor GetSysColorInfo(int iSysColor)
|
||||
{
|
||||
long lColor = ::WinQuerySysColor( HWND_DESKTOP, iSysColor, 0);
|
||||
RGB2 *pRGB2 = (RGB2*) &lColor;
|
||||
return NS_RGB( pRGB2->bRed, pRGB2->bGreen, pRGB2->bBlue);
|
||||
}
|
||||
|
||||
/* Helper function to query font from INI file */
|
||||
|
||||
void QueryFontFromINI(char* fontType, char* fontName, ULONG ulLength)
|
||||
{
|
||||
ULONG ulMaxNameL = ulLength;
|
||||
|
||||
/* We had to switch to using PrfQueryProfileData because */
|
||||
/* some users have binary font data in their INI files */
|
||||
BOOL rc = PrfQueryProfileData(HINI_USER, "PM_SystemFonts", fontType,
|
||||
fontName, &ulMaxNameL);
|
||||
/* If there was no entry in the INI, default to something */
|
||||
if (rc == FALSE) {
|
||||
/* Different values for DBCS vs. SBCS */
|
||||
if (!IsDBCS()) {
|
||||
/* WarpSans is only available on Warp 4 and above */
|
||||
if (gIsWarp4)
|
||||
strcpy(fontName, "9.WarpSans");
|
||||
else
|
||||
strcpy(fontName, "8.Helv");
|
||||
} else {
|
||||
/* WarpSans is only available on Warp 4 and above */
|
||||
if (gIsWarp4)
|
||||
strcpy(fontName, "9.WarpSans Combined");
|
||||
else
|
||||
strcpy(fontName, "10.Helv Combined");
|
||||
}
|
||||
} else {
|
||||
/* null terminate fontname */
|
||||
fontName[ulMaxNameL] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult GetSysFontInfo(nsSystemFontID aID, nsFont* aFont)
|
||||
{
|
||||
char szFontNameSize[MAXNAMEL];
|
||||
|
||||
switch (aID)
|
||||
{
|
||||
case eSystemFont_Icon:
|
||||
QueryFontFromINI("IconText", szFontNameSize, MAXNAMEL);
|
||||
break;
|
||||
|
||||
case eSystemFont_Menu:
|
||||
QueryFontFromINI("Menus", szFontNameSize, MAXNAMEL);
|
||||
break;
|
||||
|
||||
case eSystemFont_Caption:
|
||||
|
||||
case eSystemFont_MessageBox:
|
||||
|
||||
case eSystemFont_SmallCaption:
|
||||
|
||||
case eSystemFont_StatusBar:
|
||||
case eSystemFont_Tooltips:
|
||||
|
||||
case eSystemFont_Widget:
|
||||
|
||||
case eSystemFont_Window: // css3
|
||||
case eSystemFont_Document:
|
||||
case eSystemFont_Workspace:
|
||||
case eSystemFont_Desktop:
|
||||
case eSystemFont_Info:
|
||||
case eSystemFont_Dialog:
|
||||
case eSystemFont_Button:
|
||||
case eSystemFont_PullDownMenu:
|
||||
case eSystemFont_List:
|
||||
case eSystemFont_Field:
|
||||
QueryFontFromINI("WindowText", szFontNameSize, MAXNAMEL);
|
||||
break;
|
||||
} // switch
|
||||
|
||||
int pointSize;
|
||||
char *szFacename;
|
||||
|
||||
pointSize = atoi(szFontNameSize);
|
||||
szFacename = strchr(szFontNameSize, '.');
|
||||
|
||||
if ((pointSize == 0) || (!szFacename) || (*(szFacename++) == '\0')) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef OLDCODE
|
||||
PRUnichar name[FACESIZE];
|
||||
name[0] = 0;
|
||||
MultiByteToWideChar(0, szFacename,
|
||||
strlen(szFacename) + 1, name, sizeof(name)/sizeof(name[0]));
|
||||
#endif
|
||||
aFont->name.AssignWithConversion(szFacename);
|
||||
|
||||
// Do Style
|
||||
aFont->style = NS_FONT_STYLE_NORMAL;
|
||||
#if 0
|
||||
if (ptrLogFont->lfItalic)
|
||||
{
|
||||
aFont->style = NS_FONT_STYLE_ITALIC;
|
||||
}
|
||||
#endif
|
||||
// XXX What about oblique?
|
||||
|
||||
aFont->variant = NS_FONT_VARIANT_NORMAL;
|
||||
|
||||
// Do Weight
|
||||
#if 0
|
||||
aFont->weight = (ptrLogFont->lfWeight == FW_BOLD ?
|
||||
NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL);
|
||||
#else
|
||||
aFont->weight = NS_FONT_WEIGHT_NORMAL;
|
||||
#endif
|
||||
|
||||
// Do decorations
|
||||
aFont->decorations = NS_FONT_DECORATION_NONE;
|
||||
#if 0
|
||||
if (ptrLogFont->lfUnderline)
|
||||
{
|
||||
aFont->decorations |= NS_FONT_DECORATION_UNDERLINE;
|
||||
}
|
||||
if (ptrLogFont->lfStrikeOut)
|
||||
{
|
||||
aFont->decorations |= NS_FONT_DECORATION_LINE_THROUGH;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Do Size
|
||||
aFont->size = NSIntPointsToTwips(pointSize);
|
||||
|
||||
aFont->systemFont = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2 :: GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
|
||||
switch (aID) {
|
||||
case eSystemFont_Caption:
|
||||
case eSystemFont_Icon:
|
||||
case eSystemFont_Menu:
|
||||
case eSystemFont_MessageBox:
|
||||
case eSystemFont_SmallCaption:
|
||||
case eSystemFont_StatusBar:
|
||||
case eSystemFont_Tooltips:
|
||||
case eSystemFont_Widget:
|
||||
|
||||
case eSystemFont_Window: // css3
|
||||
case eSystemFont_Document:
|
||||
case eSystemFont_Workspace:
|
||||
case eSystemFont_Desktop:
|
||||
case eSystemFont_Info:
|
||||
case eSystemFont_Dialog:
|
||||
case eSystemFont_Button:
|
||||
case eSystemFont_PullDownMenu:
|
||||
case eSystemFont_List:
|
||||
case eSystemFont_Field:
|
||||
{
|
||||
status = GetSysFontInfo(aID, aFont);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2 :: CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
HPS hps = NULL;
|
||||
|
||||
if (NULL != mPrintDC){
|
||||
hps = mPrintPS;
|
||||
} else {
|
||||
hps = ::WinGetPS((HWND)mWidget);
|
||||
}
|
||||
|
||||
nsAutoCharBuffer fontName;
|
||||
PRInt32 fontNameLength;
|
||||
WideCharToMultiByte(0, aFontName.get(), aFontName.Length(),
|
||||
fontName, fontNameLength);
|
||||
|
||||
long lWant = 0;
|
||||
long lFonts = GFX (::GpiQueryFonts(hps, QF_PUBLIC | QF_PRIVATE,
|
||||
fontName.get(), &lWant, 0, 0),
|
||||
GPI_ALTERROR);
|
||||
|
||||
if (NULL == mPrintDC)
|
||||
::WinReleasePS(hps);
|
||||
|
||||
if (lFonts > 0)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
aDepth = mDepth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContextOS2::SetDPI(PRInt32 aPrefDPI)
|
||||
{
|
||||
// Set OSVal to what the operating system thinks the logical resolution is.
|
||||
long OSVal;
|
||||
HPS ps = ::WinGetScreenPS(HWND_DESKTOP);
|
||||
HDC hdc = GFX (::GpiQueryDevice (ps), HDC_ERROR);
|
||||
GFX (::DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 1, &OSVal), FALSE);
|
||||
::WinReleasePS(ps);
|
||||
|
||||
if (aPrefDPI > 0) {
|
||||
// If there's a valid pref value for the logical resolution,
|
||||
// use it.
|
||||
mDpi = aPrefDPI;
|
||||
} else if ((aPrefDPI == 0) || (OSVal > 96)) {
|
||||
// Either if the pref is 0 (force use of OS value) or the OS
|
||||
// value is bigger than 96, use the OS value.
|
||||
mDpi = OSVal;
|
||||
} else {
|
||||
// if we couldn't get the pref or it's negative, and the OS
|
||||
// value is under 96ppi, then use 96.
|
||||
mDpi = 96;
|
||||
}
|
||||
|
||||
int pt2t = 72;
|
||||
|
||||
// make p2t a nice round number - this prevents rounding problems
|
||||
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(pt2t)) / float(mDpi)));
|
||||
mTwipsToPixels = 1.0f / mPixelsToTwips;
|
||||
|
||||
// XXX need to reflow all documents
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int prefChanged(const char *aPref, void *aClosure)
|
||||
{
|
||||
nsDeviceContextOS2 *context = (nsDeviceContextOS2*)aClosure;
|
||||
nsresult rv;
|
||||
|
||||
if (nsCRT::strcmp(aPref, "layout.css.dpi")==0) {
|
||||
PRInt32 dpi;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
rv = prefs->GetIntPref(aPref, &dpi);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
context->SetDPI(dpi);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2 :: GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
|
||||
{
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
// Defer to Alt when there is one
|
||||
if (mAltDC && (mUseAltDC & kUseAltDCFor_SURFACE_DIM))
|
||||
return mAltDC->GetDeviceSurfaceDimensions(aWidth, aHeight);
|
||||
#endif
|
||||
|
||||
if ( mSpec )
|
||||
{
|
||||
// we have a printer device
|
||||
aWidth = NSToIntRound(mWidth * mDevUnitsToAppUnits);
|
||||
aHeight = NSToIntRound(mHeight * mDevUnitsToAppUnits);
|
||||
}
|
||||
else {
|
||||
nsRect area;
|
||||
ComputeFullAreaUsingScreen ( &area );
|
||||
aWidth = area.width;
|
||||
aHeight = area.height;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2 :: GetRect(nsRect &aRect)
|
||||
{
|
||||
if ( mSpec )
|
||||
{
|
||||
// we have a printer device
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
|
||||
aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
|
||||
}
|
||||
else
|
||||
ComputeFullAreaUsingScreen ( &aRect );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2 :: GetClientRect(nsRect &aRect)
|
||||
{
|
||||
if ( mSpec )
|
||||
{
|
||||
// we have a printer device
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
|
||||
aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
|
||||
}
|
||||
else
|
||||
ComputeClientRectUsingScreen ( &aRect );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextOS2 :: GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext)
|
||||
{
|
||||
PRTQUEUE *pq;
|
||||
|
||||
aContext = new nsDeviceContextOS2();
|
||||
if(nsnull != aContext){
|
||||
NS_ADDREF(aContext);
|
||||
} else {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
((nsDeviceContextOS2 *)aContext)->mSpec = aDevice;
|
||||
NS_ADDREF(aDevice);
|
||||
|
||||
int numCopies = 0;
|
||||
int printerDest = 0;
|
||||
char *file = nsnull;
|
||||
|
||||
((nsDeviceContextSpecOS2 *)aDevice)->GetPRTQUEUE(pq);
|
||||
((nsDeviceContextSpecOS2 *)aDevice)->GetCopies(numCopies);
|
||||
((nsDeviceContextSpecOS2 *)aDevice)->GetDestination(printerDest);
|
||||
if (!printerDest)
|
||||
((nsDeviceContextSpecOS2 *)aDevice)->GetPath(&file);
|
||||
|
||||
HDC dc = PrnOpenDC(pq, "Mozilla", numCopies, printerDest, file);
|
||||
|
||||
if (!dc) {
|
||||
return NS_ERROR_FAILURE; //PMERROR("DevOpenDC");
|
||||
} /* endif */
|
||||
|
||||
return ((nsDeviceContextOS2 *)aContext)->Init((nsNativeDeviceContext)dc, this);
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::CreateFontAliasTable()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if( !mFontAliasTable)
|
||||
{
|
||||
mFontAliasTable = new nsHashtable;
|
||||
|
||||
nsAutoString times; times.AssignLiteral("Times");
|
||||
nsAutoString timesNewRoman; timesNewRoman.AssignLiteral("Times New Roman");
|
||||
nsAutoString timesRoman; timesRoman.AssignLiteral("Tms Rmn");
|
||||
nsAutoString arial; arial.AssignLiteral("Arial");
|
||||
nsAutoString helv; helv.AssignLiteral("Helv");
|
||||
nsAutoString helvetica; helvetica.AssignLiteral("Helvetica");
|
||||
nsAutoString courier; courier.AssignLiteral("Courier");
|
||||
nsAutoString courierNew; courierNew.AssignLiteral("Courier New");
|
||||
nsAutoString sans; sans.AssignLiteral("Sans");
|
||||
nsAutoString unicode; unicode.AssignLiteral("Unicode");
|
||||
nsAutoString timesNewRomanMT30; timesNewRomanMT30.AssignLiteral("Times New Roman MT 30");
|
||||
nsAutoString nullStr;
|
||||
|
||||
AliasFont(times, timesNewRoman, timesRoman, PR_FALSE);
|
||||
AliasFont(timesRoman, timesNewRoman, times, PR_FALSE);
|
||||
AliasFont(timesNewRoman, timesRoman, times, PR_FALSE);
|
||||
AliasFont(arial, helv, helvetica, PR_FALSE);
|
||||
AliasFont(helvetica, helv, arial, PR_FALSE);
|
||||
AliasFont(courier, courierNew, nullStr, PR_TRUE);
|
||||
AliasFont(courierNew, courier, nullStr, PR_FALSE);
|
||||
AliasFont(sans, helv, arial, PR_FALSE);
|
||||
|
||||
// Is this right?
|
||||
AliasFont(unicode, timesNewRomanMT30, nullStr, PR_FALSE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Printing ------------------------------------------------------------------
|
||||
nsresult nsDeviceContextOS2::PrepareDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (NULL != mPrintDC){
|
||||
nsString titleStr;
|
||||
titleStr = aTitle;
|
||||
char *title = GetACPString(titleStr);
|
||||
|
||||
PSZ pszDocName;
|
||||
const PSZ pszGenericDocName = "MozillaDocument";
|
||||
|
||||
if (title) {
|
||||
pszDocName = title;
|
||||
} else {
|
||||
pszDocName = pszGenericDocName;
|
||||
}
|
||||
|
||||
long lDummy = 0;
|
||||
long lResult = ::DevEscape(mPrintDC, DEVESC_STARTDOC,
|
||||
strlen(pszDocName) + 1, pszDocName,
|
||||
&lDummy, NULL);
|
||||
|
||||
mPrintingStarted = PR_TRUE;
|
||||
|
||||
if (lResult == DEV_OK)
|
||||
rv = NS_OK;
|
||||
else
|
||||
rv = NS_ERROR_GFX_PRINTER_STARTDOC;
|
||||
|
||||
if (title != nsnull) {
|
||||
nsMemory::Free(title);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
// Everything is done in PrepareDocument
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::EndDocument()
|
||||
{
|
||||
if (NULL != mPrintDC)
|
||||
{
|
||||
long lOutCount = 2;
|
||||
USHORT usJobID = 0;
|
||||
long lResult = ::DevEscape(mPrintDC, DEVESC_ENDDOC,
|
||||
0, NULL,
|
||||
&lOutCount, (PBYTE)&usJobID);
|
||||
if (lResult == DEV_OK)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_GFX_PRINTER_ENDDOC;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::AbortDocument()
|
||||
{
|
||||
if (NULL != mPrintDC)
|
||||
{
|
||||
long ldummy = 0;
|
||||
long lResult = ::DevEscape(mPrintDC, DEVESC_ABORTDOC, 0, NULL,
|
||||
&ldummy, NULL);
|
||||
if (lResult == DEV_OK)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsDeviceContextOS2::BeginPage()
|
||||
{
|
||||
if (mPrintingStarted) {
|
||||
mPrintingStarted = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NULL != mPrintDC)
|
||||
{
|
||||
long lDummy = 0;
|
||||
long lResult = ::DevEscape(mPrintDC, DEVESC_NEWFRAME, 0, NULL,
|
||||
&lDummy, NULL);
|
||||
|
||||
if (lResult == DEV_OK)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_GFX_PRINTER_STARTPAGE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::EndPage()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char*
|
||||
nsDeviceContextOS2::GetACPString(const nsString& aStr)
|
||||
{
|
||||
if (aStr.Length() == 0) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsAutoCharBuffer acp;
|
||||
PRInt32 acpLength;
|
||||
WideCharToMultiByte(0, aStr.get(), aStr.Length(), acp, acpLength);
|
||||
return ToNewCString(nsDependentCString(acp.get()));
|
||||
}
|
||||
|
||||
BOOL nsDeviceContextOS2::isPrintDC()
|
||||
{
|
||||
if ( mPrintDC == nsnull )
|
||||
return 0;
|
||||
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
PRBool nsDeviceContextOS2::SupportsRasterFonts()
|
||||
{
|
||||
return mSupportsRasterFonts;
|
||||
}
|
@ -1,133 +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 nsDeviceContextOS2_h___
|
||||
#define nsDeviceContextOS2_h___
|
||||
|
||||
#include "nsGfxDefs.h"
|
||||
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsDeviceContextSpecOS2.h"
|
||||
|
||||
class nsIScreen;
|
||||
|
||||
class nsDeviceContextOS2 : public DeviceContextImpl
|
||||
{
|
||||
public:
|
||||
nsDeviceContextOS2();
|
||||
|
||||
NS_IMETHOD Init(nsNativeWidget aWidget);
|
||||
|
||||
using DeviceContextImpl::CreateRenderingContext;
|
||||
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
|
||||
|
||||
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
|
||||
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
NS_IMETHOD GetRect(nsRect &aRect);
|
||||
NS_IMETHOD GetClientRect(nsRect &aRect);
|
||||
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD PrepareDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
NS_IMETHOD EndPage(void);
|
||||
|
||||
// Static Helper Methods
|
||||
static char* GetACPString(const nsString& aStr);
|
||||
nsresult SetDPI(PRInt32 aPrefDPI);
|
||||
int GetDPI() { return mDpi; };
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextOS2();
|
||||
void CommonInit(HDC aDC);
|
||||
nsresult Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext);
|
||||
void FindScreen ( nsIScreen** outScreen ) ;
|
||||
void ComputeClientRectUsingScreen ( nsRect* outRect ) ;
|
||||
void ComputeFullAreaUsingScreen ( nsRect* outRect ) ;
|
||||
|
||||
PRBool mCachedClientRect;
|
||||
PRBool mCachedFullRect;
|
||||
PRBool mPrintingStarted;
|
||||
|
||||
nsIDrawingSurface* mSurface;
|
||||
PRUint32 mDepth; // bit depth of device
|
||||
PRBool mIsPaletteDevice;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
nsRect mClientRect;
|
||||
nsIDeviceContextSpec *mSpec;
|
||||
PRBool mSupportsRasterFonts;
|
||||
|
||||
nsCOMPtr<nsIScreenManager> mScreenManager;
|
||||
static PRUint32 sNumberOfScreens;
|
||||
static nscoord mDpi;
|
||||
|
||||
public:
|
||||
HDC mPrintDC;
|
||||
HPS mPrintPS;
|
||||
|
||||
enum nsPrintState
|
||||
{
|
||||
nsPrintState_ePreBeginDoc,
|
||||
nsPrintState_eBegunDoc,
|
||||
nsPrintState_eBegunFirstPage,
|
||||
nsPrintState_eEndedDoc
|
||||
} mPrintState;
|
||||
|
||||
BOOL isPrintDC();
|
||||
PRBool SupportsRasterFonts();
|
||||
PRBool IsPaletteDevice() {return mIsPaletteDevice;};
|
||||
nsresult CreateFontAliasTable();
|
||||
};
|
||||
|
||||
int PR_CALLBACK prefChanged(const char *aPref, void *aClosure);
|
||||
|
||||
#endif /* nsDeviceContextOS2_h___ */
|
@ -1,623 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.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 "nsGfxDefs.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsDrawingSurfaceOS2.h"
|
||||
#include "nsFontMetricsOS2.h"
|
||||
#include "nsPaletteOS2.h"
|
||||
|
||||
#define LCID_START 2
|
||||
|
||||
|
||||
// Base class -- fonts, palette and xpcom -----------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDrawingSurfaceOS2, nsIDrawingSurface)
|
||||
|
||||
// We start allocated lCIDs at 2. This leaves #1 for nsFontMetricsOS2 to
|
||||
// do testing with, and 0 is, of course, LCID_DEFAULT.
|
||||
|
||||
nsDrawingSurfaceOS2::nsDrawingSurfaceOS2()
|
||||
: mNextID(LCID_START), mTopID(1), mPS(0), mOwnPS(PR_FALSE),
|
||||
mWidth (0), mHeight (0)
|
||||
{
|
||||
mHTFonts = new nsHashtable;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceOS2::~nsDrawingSurfaceOS2()
|
||||
{
|
||||
DisposeFonts();
|
||||
}
|
||||
|
||||
void nsDrawingSurfaceOS2::DisposeFonts()
|
||||
{
|
||||
if( mHTFonts)
|
||||
{
|
||||
// free font things
|
||||
GFX (::GpiSetCharSet(mPS, LCID_DEFAULT), FALSE);
|
||||
|
||||
for (int i = LCID_START; i <= mTopID; i++) {
|
||||
GFX (::GpiDeleteSetId(mPS, i), FALSE);
|
||||
}
|
||||
delete mHTFonts;
|
||||
mHTFonts = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Key for the hashtable
|
||||
typedef nsVoidKey FontHandleKey;
|
||||
|
||||
void nsDrawingSurfaceOS2::SelectFont(nsFontOS2* aFont)
|
||||
{
|
||||
FontHandleKey key((void*)aFont->mHashMe);
|
||||
|
||||
long lcid = (long) mHTFonts->Get(&key);
|
||||
if (lcid == 0) {
|
||||
if (mNextID == 255) {
|
||||
// ids used up, need to empty table and start again.
|
||||
FlushFontCache();
|
||||
}
|
||||
|
||||
lcid = mNextID;
|
||||
mNextID++;
|
||||
CHK_SUCCESS (::GpiCreateLogFont(mPS, 0, lcid, &aFont->mFattrs),
|
||||
FONT_MATCH);
|
||||
mHTFonts->Put(&key, (void *) lcid);
|
||||
if (mTopID < 254) {
|
||||
mTopID++;
|
||||
}
|
||||
}
|
||||
|
||||
aFont->SelectIntoPS(mPS, lcid);
|
||||
}
|
||||
|
||||
void nsDrawingSurfaceOS2::FlushFontCache()
|
||||
{
|
||||
mHTFonts->Reset();
|
||||
mNextID = LCID_START;
|
||||
// leave mTopID where it is.
|
||||
}
|
||||
|
||||
// OS/2 - XP coord conversion ----------------------------------------------
|
||||
|
||||
// get inclusive-inclusive rect
|
||||
void nsDrawingSurfaceOS2::NS2PM_ININ( const nsRect &in, RECTL &rcl)
|
||||
{
|
||||
const static nscoord kBottomLeftLimit = -8192;
|
||||
const static nscoord kTopRightLimit = 16384;
|
||||
|
||||
PRInt32 ulHeight = GetHeight ();
|
||||
|
||||
rcl.xLeft = PR_MAX(kBottomLeftLimit, in.x);
|
||||
rcl.xRight = PR_MIN(in.x+in.width-1, kTopRightLimit);
|
||||
rcl.yTop = PR_MIN(ulHeight-in.y-1, kTopRightLimit);
|
||||
rcl.yBottom = PR_MAX(rcl.yTop-in.height+1, kBottomLeftLimit);
|
||||
return;
|
||||
}
|
||||
|
||||
void nsDrawingSurfaceOS2::PM2NS_ININ( const RECTL &in, nsRect &out)
|
||||
{
|
||||
PRInt32 ulHeight = GetHeight ();
|
||||
|
||||
out.x = in.xLeft;
|
||||
out.width = in.xRight - in.xLeft + 1;
|
||||
out.y = ulHeight - in.yTop - 1;
|
||||
out.height = in.yTop - in.yBottom + 1;
|
||||
}
|
||||
|
||||
// get in-ex rect
|
||||
void nsDrawingSurfaceOS2::NS2PM_INEX( const nsRect &in, RECTL &rcl)
|
||||
{
|
||||
NS2PM_ININ( in, rcl);
|
||||
rcl.xRight++;
|
||||
rcl.yTop++;
|
||||
}
|
||||
|
||||
void nsDrawingSurfaceOS2::NS2PM( PPOINTL aPointl, ULONG cPointls)
|
||||
{
|
||||
PRInt32 ulHeight = GetHeight ();
|
||||
|
||||
for( ULONG i = 0; i < cPointls; i++)
|
||||
aPointl[ i].y = ulHeight - aPointl[ i].y - 1;
|
||||
}
|
||||
|
||||
nsresult nsDrawingSurfaceOS2::GetDimensions( PRUint32 *aWidth, PRUint32 *aHeight)
|
||||
{
|
||||
if( !aWidth || !aHeight)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aWidth = mWidth;
|
||||
*aHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Offscreen surface --------------------------------------------------------
|
||||
|
||||
nsOffscreenSurface::nsOffscreenSurface() : mDC(0), mBitmap(0),
|
||||
mInfoHeader(0), mBits(0),
|
||||
mYPels(0), mScans(0)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOffscreenSurface :: Init(HPS aPS)
|
||||
{
|
||||
mPS = aPS;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Setup a new offscreen surface which is to be compatible with the
|
||||
// passed-in presentation space.
|
||||
nsresult nsOffscreenSurface::Init( HPS aCompatiblePS,
|
||||
PRInt32 aWidth, PRInt32 aHeight, PRUint32 aFlags)
|
||||
{
|
||||
nsresult rc = NS_ERROR_FAILURE;
|
||||
|
||||
// Find the compatible device context and create a memory one
|
||||
HDC hdcCompat = GFX (::GpiQueryDevice (aCompatiblePS), HDC_ERROR);
|
||||
DEVOPENSTRUC dop = { 0, 0, 0, 0, 0 };
|
||||
mDC = GFX (::DevOpenDC( 0/*hab*/, OD_MEMORY, "*", 5, (PDEVOPENDATA) &dop, hdcCompat), DEV_ERROR);
|
||||
|
||||
if( DEV_ERROR != mDC)
|
||||
{
|
||||
// create the PS
|
||||
SIZEL sizel = { 0, 0 };
|
||||
mPS = GFX (::GpiCreatePS (0/*hab*/, mDC, &sizel,
|
||||
PU_PELS | GPIT_MICRO | GPIA_ASSOC), GPI_ERROR);
|
||||
|
||||
if( GPI_ERROR != mPS)
|
||||
{
|
||||
mOwnPS = PR_TRUE;
|
||||
|
||||
nsPaletteOS2::SelectGlobalPalette(mPS);
|
||||
|
||||
// now create a bitmap of the right size
|
||||
BITMAPINFOHEADER2 hdr = { 0 };
|
||||
|
||||
hdr.cbFix = sizeof( BITMAPINFOHEADER2);
|
||||
hdr.cx = aWidth;
|
||||
hdr.cy = aHeight;
|
||||
hdr.cPlanes = 1;
|
||||
|
||||
// find bitdepth
|
||||
LONG lBitCount = 0;
|
||||
GFX (::DevQueryCaps( hdcCompat, CAPS_COLOR_BITCOUNT, 1, &lBitCount), FALSE);
|
||||
hdr.cBitCount = (USHORT) lBitCount;
|
||||
|
||||
mBitmap = GFX (::GpiCreateBitmap (mPS, &hdr, 0, 0, 0), GPI_ERROR);
|
||||
|
||||
if( GPI_ERROR != mBitmap)
|
||||
{
|
||||
// set final stats & select bitmap into ps
|
||||
mHeight = aHeight;
|
||||
mWidth = aWidth;
|
||||
GFX (::GpiSetBitmap (mPS, mBitmap), HBM_ERROR);
|
||||
rc = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
nsOffscreenSurface::~nsOffscreenSurface()
|
||||
{
|
||||
DisposeFonts();
|
||||
|
||||
if (mBitmap) {
|
||||
GFX (::GpiSetBitmap (mPS, 0), HBM_ERROR);
|
||||
GFX (::GpiDeleteBitmap (mBitmap), FALSE);
|
||||
}
|
||||
if (mOwnPS) {
|
||||
GFX (::GpiDestroyPS (mPS), FALSE);
|
||||
}
|
||||
if (mDC) {
|
||||
::DevCloseDC(mDC);
|
||||
}
|
||||
|
||||
if( mInfoHeader)
|
||||
free( mInfoHeader);
|
||||
delete [] mBits;
|
||||
}
|
||||
|
||||
// Okay; plan here is to get the bits and hope that the fact that we're
|
||||
// returning an upside-down rectangle doesn't matter.
|
||||
//
|
||||
// If it does, then the following needs to be done:
|
||||
//
|
||||
// * undefine the USD flag in libimg
|
||||
// * alter the draw code in nsImageOS2 to draw right-way-up
|
||||
// * fix the printing case (probably involving an ugly xform)
|
||||
//
|
||||
nsresult nsOffscreenSurface::Lock( PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
// Trust other platforms to ensure that we don't get nested!
|
||||
PRInt32 lStride = 0;
|
||||
ULONG rc = 0;
|
||||
|
||||
// Allocate buffers first time we get called.
|
||||
//
|
||||
// Need to look at the way in which this functionality is exercised:
|
||||
// may actually be more efficient to only grab the section of bitmap
|
||||
// required on each call, and to free up memory afterwards.
|
||||
//
|
||||
// Currently: * allocate once enough space for the entire bitmap
|
||||
// * only grab & set the required scanlines
|
||||
//
|
||||
if( !mBits)
|
||||
{
|
||||
BITMAPINFOHEADER bih = { sizeof( BITMAPINFOHEADER), 0, 0, 0, 0 };
|
||||
|
||||
rc = GFX (::GpiQueryBitmapInfoHeader (mBitmap, (PBITMAPINFOHEADER2) &bih), FALSE);
|
||||
|
||||
// alloc space to query pel data into...
|
||||
lStride = RASWIDTH( bih.cx, bih.cBitCount);
|
||||
mBits = new PRUint8 [ lStride * bih.cy ];
|
||||
|
||||
// ..and colour table too
|
||||
int cols = -1;
|
||||
if( bih.cBitCount >= 24) cols = 0;
|
||||
else cols = 1 << bih.cBitCount;
|
||||
|
||||
int szStruct = sizeof( BITMAPINFOHEADER2) + cols * sizeof( RGB2);
|
||||
|
||||
mInfoHeader = (PBITMAPINFOHEADER2) calloc( szStruct, 1);
|
||||
mInfoHeader->cbFix = sizeof( BITMAPINFOHEADER2);
|
||||
mInfoHeader->cx = bih.cx;
|
||||
mInfoHeader->cy = bih.cy;
|
||||
mInfoHeader->cPlanes = 1;
|
||||
mInfoHeader->cBitCount = (USHORT) bih.cBitCount;
|
||||
// GPI-Ref says these have to be set too...
|
||||
mInfoHeader->ulCompression = BCA_UNCOMP;
|
||||
mInfoHeader->usRecording = BRA_BOTTOMUP;
|
||||
mInfoHeader->usRendering = BRH_NOTHALFTONED; // ...hmm...
|
||||
mInfoHeader->ulColorEncoding = BCE_RGB;
|
||||
}
|
||||
else
|
||||
lStride = RASWIDTH( mInfoHeader->cx, mInfoHeader->cBitCount);
|
||||
|
||||
// record starting scanline (bottom is 0)
|
||||
mYPels = mInfoHeader->cy - aY - aHeight;
|
||||
mScans = aHeight;
|
||||
|
||||
rc = GFX (::GpiQueryBitmapBits (mPS, mYPels, mScans, (PBYTE)mBits,
|
||||
(PBITMAPINFO2)mInfoHeader), GPI_ALTERROR);
|
||||
|
||||
#ifdef DEBUG
|
||||
if( rc != mScans) {
|
||||
PMERROR( "GpiQueryBitmapBits");
|
||||
printf( "Lock, requested %d x %d and got %d x %d\n",
|
||||
aWidth, aHeight, (int) mInfoHeader->cx, aHeight);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Okay. Now have current state of bitmap in mBits.
|
||||
*aStride = lStride;
|
||||
*aBits = (void*) (mBits + (aX * (mInfoHeader->cBitCount >> 3)));
|
||||
*aWidthBytes = aWidth * (mInfoHeader->cBitCount >> 3);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsOffscreenSurface::Unlock()
|
||||
{
|
||||
GFX (::GpiSetBitmapBits (mPS, mYPels, mScans, (PBYTE)mBits,
|
||||
(PBITMAPINFO2)mInfoHeader), GPI_ALTERROR);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsOffscreenSurface::IsOffscreen( PRBool *aOffScreen)
|
||||
{
|
||||
if( !aOffScreen)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aOffScreen = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsOffscreenSurface::IsPixelAddressable( PRBool *aAddressable)
|
||||
{
|
||||
if( !aAddressable)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aAddressable = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsOffscreenSurface::GetPixelFormat( nsPixelFormat *aFormat)
|
||||
{
|
||||
if( !aFormat)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Okay. Who knows what's going on here - we (as wz) currently support
|
||||
// only 8 and 24 bpp bitmaps; dunno what should be done for 32 bpp,
|
||||
// even if os/2 supports them.
|
||||
//
|
||||
// (prob'ly need to get the FOURCC stuff into the act for 16bpp?)
|
||||
//
|
||||
BITMAPINFOHEADER bih = { sizeof( BITMAPINFOHEADER), 0, 0, 0, 0 };
|
||||
GFX (::GpiQueryBitmapInfoHeader (mBitmap, (PBITMAPINFOHEADER2)&bih), FALSE);
|
||||
|
||||
switch( bih.cBitCount)
|
||||
{
|
||||
case 8:
|
||||
memset( aFormat, 0, sizeof(nsPixelFormat));
|
||||
break;
|
||||
|
||||
case 16:
|
||||
aFormat->mRedZeroMask = 0x001F;
|
||||
aFormat->mGreenZeroMask = 0x003F;
|
||||
aFormat->mBlueZeroMask = 0x001F;
|
||||
aFormat->mAlphaZeroMask = 0;
|
||||
aFormat->mRedMask = 0xF800;
|
||||
aFormat->mGreenMask = 0x07E0;
|
||||
aFormat->mBlueMask = 0x001F;
|
||||
aFormat->mAlphaMask = 0;
|
||||
aFormat->mRedCount = 5;
|
||||
aFormat->mGreenCount = 6;
|
||||
aFormat->mBlueCount = 5;
|
||||
aFormat->mAlphaCount = 0;
|
||||
aFormat->mRedShift = 11;
|
||||
aFormat->mGreenShift = 5;
|
||||
aFormat->mBlueShift = 0;
|
||||
aFormat->mAlphaShift = 0;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
aFormat->mRedZeroMask = 0x0000FF;
|
||||
aFormat->mGreenZeroMask = 0x0000FF;
|
||||
aFormat->mBlueZeroMask = 0x0000FF;
|
||||
aFormat->mAlphaZeroMask = 0;
|
||||
aFormat->mRedMask = 0x0000FF;
|
||||
aFormat->mGreenMask = 0x00FF00;
|
||||
aFormat->mBlueMask = 0xFF0000;
|
||||
aFormat->mAlphaMask = 0;
|
||||
aFormat->mRedCount = 8;
|
||||
aFormat->mGreenCount = 8;
|
||||
aFormat->mBlueCount = 8;
|
||||
aFormat->mAlphaCount = 0;
|
||||
aFormat->mRedShift = 0;
|
||||
aFormat->mGreenShift = 8;
|
||||
aFormat->mBlueShift = 16;
|
||||
aFormat->mAlphaShift = 0;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
aFormat->mRedZeroMask = 0x000000FF;
|
||||
aFormat->mGreenZeroMask = 0x000000FF;
|
||||
aFormat->mBlueZeroMask = 0x000000FF;
|
||||
aFormat->mAlphaZeroMask = 0x000000FF;
|
||||
aFormat->mRedMask = 0x00FF0000;
|
||||
aFormat->mGreenMask = 0x0000FF00;
|
||||
aFormat->mBlueMask = 0x000000FF;
|
||||
aFormat->mAlphaMask = 0xFF000000;
|
||||
aFormat->mRedCount = 8;
|
||||
aFormat->mGreenCount = 8;
|
||||
aFormat->mBlueCount = 8;
|
||||
aFormat->mAlphaCount = 8;
|
||||
aFormat->mRedShift = 16;
|
||||
aFormat->mGreenShift = 8;
|
||||
aFormat->mBlueShift = 0;
|
||||
aFormat->mAlphaShift = 24;
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef DEBUG
|
||||
printf( "Bad bit-depth for GetPixelFormat (%d)\n", bih.cBitCount);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Non-offscreen surfaces, base for window & print --------------------------
|
||||
nsOnscreenSurface::nsOnscreenSurface() : mProxySurface(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsOnscreenSurface::~nsOnscreenSurface()
|
||||
{
|
||||
NS_IF_RELEASE(mProxySurface);
|
||||
}
|
||||
|
||||
void nsOnscreenSurface::EnsureProxy()
|
||||
{
|
||||
if( !mProxySurface)
|
||||
{
|
||||
PRUint32 width, height;
|
||||
GetDimensions( &width, &height);
|
||||
|
||||
mProxySurface = new nsOffscreenSurface;
|
||||
if( NS_SUCCEEDED(mProxySurface->Init( mPS, width, height, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS)))
|
||||
{
|
||||
NS_ADDREF(mProxySurface);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete mProxySurface;
|
||||
mProxySurface = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsOnscreenSurface::Lock( PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
EnsureProxy();
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "Locking through a proxy\n");
|
||||
#endif
|
||||
|
||||
// blit our 'real' bitmap to the proxy surface
|
||||
PRUint32 width, height;
|
||||
GetDimensions( &width, &height);
|
||||
POINTL pts[3] = { { 0, 0 }, { width, height }, { 0, 0 } };
|
||||
GFX (::GpiBitBlt (mProxySurface->GetPS (), mPS, 3, pts,
|
||||
ROP_SRCCOPY, BBO_OR), GPI_ERROR);
|
||||
|
||||
return mProxySurface->Lock( aX, aY, aWidth, aHeight,
|
||||
aBits, aStride, aWidthBytes, aFlags);
|
||||
}
|
||||
|
||||
nsresult nsOnscreenSurface::Unlock()
|
||||
{
|
||||
nsresult rc = mProxySurface->Unlock();
|
||||
|
||||
// blit proxy bitmap back to ours
|
||||
PRUint32 width, height;
|
||||
GetDimensions( &width, &height);
|
||||
POINTL pts[3] = { { 0, 0 }, { width, height }, { 0, 0 } };
|
||||
GFX (::GpiBitBlt (mPS, mProxySurface->GetPS (), 3, pts,
|
||||
ROP_SRCCOPY, BBO_OR), GPI_ERROR);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
nsresult nsOnscreenSurface::GetPixelFormat( nsPixelFormat *aFormat)
|
||||
{
|
||||
EnsureProxy();
|
||||
return mProxySurface->GetPixelFormat( aFormat);
|
||||
}
|
||||
|
||||
nsresult nsOnscreenSurface::IsOffscreen( PRBool *aOffScreen)
|
||||
{
|
||||
if( !aOffScreen)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aOffScreen = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsOnscreenSurface::IsPixelAddressable( PRBool *aAddressable)
|
||||
{
|
||||
if( !aAddressable)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aAddressable = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Surface for a PM window --------------------------------------------------
|
||||
nsWindowSurface::nsWindowSurface() : mWidget(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsWindowSurface::~nsWindowSurface()
|
||||
{
|
||||
// palette will be deselected in superclass dtor
|
||||
|
||||
// need to do this now because hps is invalid after subsequent free
|
||||
DisposeFonts();
|
||||
|
||||
// release hps if we had instantiated it
|
||||
if (mOwnPS) {
|
||||
mWidget->FreeNativeData( (void*) mPS, NS_NATIVE_GRAPHIC);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowSurface::Init(HPS aPS, nsIWidget *aWidget)
|
||||
{
|
||||
mPS = aPS;
|
||||
mWidget = aWidget;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsWindowSurface::Init( nsIWidget *aOwner)
|
||||
{
|
||||
mWidget = aOwner;
|
||||
mPS = (HPS) mWidget->GetNativeData( NS_NATIVE_GRAPHIC);
|
||||
mOwnPS = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsWindowSurface::GetDimensions( PRUint32 *aWidth, PRUint32 *aHeight)
|
||||
{
|
||||
// I don't think we can be more efficient than this, except perhaps by
|
||||
// doing some kind of `push' of height from the window to us.
|
||||
nsRect rect;
|
||||
mWidget->GetClientBounds( rect);
|
||||
*aHeight = rect.height;
|
||||
*aWidth = rect.width;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32 nsWindowSurface::GetHeight ()
|
||||
{
|
||||
nsRect rect;
|
||||
|
||||
mWidget->GetClientBounds (rect);
|
||||
|
||||
return rect.height;
|
||||
}
|
||||
|
||||
// Printer surface. A few minor differences, like the page size is fixed ---
|
||||
nsPrintSurface::nsPrintSurface()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult nsPrintSurface::Init( HPS aPS, PRInt32 aWidth, PRInt32 aHeight, PRUint32 aFlags)
|
||||
{
|
||||
mPS = aPS;
|
||||
mHeight = aHeight;
|
||||
mWidth = aWidth;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsPrintSurface::~nsPrintSurface()
|
||||
{
|
||||
// PS is owned by the DC; superclass dtor will deselect palette.
|
||||
}
|
@ -1,184 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* 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 *****
|
||||
* 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
|
||||
* 03/28/2000 IBM Corp. Changes to make os2.h file similar to windows.h file
|
||||
*/
|
||||
|
||||
#ifndef _nsDrawingSurfaceOS2_h
|
||||
#define _nsDrawingSurfaceOS2_h
|
||||
|
||||
#include "nsIDrawingSurface.h"
|
||||
|
||||
class nsHashtable;
|
||||
class nsIWidget;
|
||||
class nsFontOS2;
|
||||
|
||||
// These were called `drawables' in os2fe.
|
||||
//
|
||||
// Note that each surface has a ref to the palette of the device context
|
||||
// from which it was spun off. This is because drawing surfaces have
|
||||
// lifetimes which extend further than the rendering context which
|
||||
// created them. The creating object must select the palette into the
|
||||
// surface's presentation space; all the drawing surface does is deselect
|
||||
// the palette when it's dying.
|
||||
//
|
||||
// This is rather unwieldy...
|
||||
|
||||
class nsDrawingSurfaceOS2 : public nsIDrawingSurface
|
||||
{
|
||||
nsHashtable *mHTFonts; // cache of fonthandle to lcid
|
||||
long mNextID; // next lcid to allocate
|
||||
long mTopID; // highest used lcid
|
||||
|
||||
protected:
|
||||
HPS mPS; // presentation space for this surface
|
||||
PRBool mOwnPS; // did we instantiate PS or was it passed in?
|
||||
PRInt32 mWidth; // dimensions of drawing surface
|
||||
PRInt32 mHeight;
|
||||
|
||||
|
||||
nsDrawingSurfaceOS2();
|
||||
virtual ~nsDrawingSurfaceOS2();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
void DisposeFonts(); // MUST be called before disposing of PS
|
||||
|
||||
|
||||
public:
|
||||
NS_IMETHOD GetDimensions( PRUint32 *aWidth, PRUint32 *aHeight);
|
||||
|
||||
// os/2 methods
|
||||
HPS GetPS() { return mPS; }
|
||||
void SelectFont(nsFontOS2* aFont);
|
||||
void FlushFontCache();
|
||||
virtual PRUint32 GetHeight() { return mHeight; }
|
||||
|
||||
// Convertion between XP and OS/2 coordinate space.
|
||||
void NS2PM_ININ (const nsRect &in, RECTL &rcl);
|
||||
void NS2PM_INEX (const nsRect &in, RECTL &rcl);
|
||||
void PM2NS_ININ (const RECTL &in, nsRect &out);
|
||||
void NS2PM (PPOINTL aPointl, ULONG cPointls);
|
||||
};
|
||||
|
||||
// Offscreen surface. Others depend on this.
|
||||
class nsOffscreenSurface : public nsDrawingSurfaceOS2
|
||||
{
|
||||
HDC mDC;
|
||||
HBITMAP mBitmap;
|
||||
|
||||
PBITMAPINFOHEADER2 mInfoHeader;
|
||||
PRUint8 *mBits;
|
||||
|
||||
PRInt32 mYPels;
|
||||
PRUint32 mScans;
|
||||
|
||||
public:
|
||||
nsOffscreenSurface();
|
||||
virtual ~nsOffscreenSurface();
|
||||
|
||||
// os/2 methods
|
||||
NS_IMETHOD Init( HPS aCompatiblePS, PRInt32 aWidth, PRInt32 aHeight, PRUint32 aFlags);
|
||||
NS_IMETHOD Init(HPS aPS);
|
||||
|
||||
HDC GetDC() { return mDC; }
|
||||
|
||||
// nsIDrawingSurface methods
|
||||
NS_IMETHOD Lock( PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD Unlock();
|
||||
NS_IMETHOD IsOffscreen( PRBool *aOffScreen);
|
||||
NS_IMETHOD IsPixelAddressable( PRBool *aAddressable);
|
||||
NS_IMETHOD GetPixelFormat( nsPixelFormat *aFormat);
|
||||
};
|
||||
|
||||
// Onscreen surface - uses an offscreen to implement bitlevel access
|
||||
class nsOnscreenSurface : public nsDrawingSurfaceOS2
|
||||
{
|
||||
nsOffscreenSurface *mProxySurface;
|
||||
void EnsureProxy();
|
||||
|
||||
protected:
|
||||
nsOnscreenSurface();
|
||||
virtual ~nsOnscreenSurface();
|
||||
|
||||
public:
|
||||
// nsIDrawingSurface methods
|
||||
NS_IMETHOD Lock( PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD Unlock();
|
||||
NS_IMETHOD IsOffscreen( PRBool *aOffScreen);
|
||||
NS_IMETHOD IsPixelAddressable( PRBool *aAddressable);
|
||||
NS_IMETHOD GetPixelFormat( nsPixelFormat *aFormat);
|
||||
};
|
||||
|
||||
// Surface for an onscreen window
|
||||
class nsWindowSurface : public nsOnscreenSurface
|
||||
{
|
||||
nsIWidget *mWidget; // window who owns the surface
|
||||
|
||||
public:
|
||||
nsWindowSurface();
|
||||
virtual ~nsWindowSurface();
|
||||
|
||||
NS_IMETHOD Init(HPS aPS, nsIWidget *aWidget);
|
||||
NS_IMETHOD Init( nsIWidget *aOwner);
|
||||
NS_IMETHOD GetDimensions( PRUint32 *aWidth, PRUint32 *aHeight);
|
||||
|
||||
virtual PRUint32 GetHeight ();
|
||||
};
|
||||
|
||||
// Surface for a printer-page
|
||||
class nsPrintSurface : public nsOnscreenSurface
|
||||
{
|
||||
public:
|
||||
nsPrintSurface();
|
||||
virtual ~nsPrintSurface();
|
||||
|
||||
NS_IMETHOD Init( HPS aPS, PRInt32 aWidth, PRInt32 aHeight, PRUint32 aFlags);
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,461 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* 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 *****
|
||||
*
|
||||
* 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
|
||||
* 03/28/2000 IBM Corp. Changes to make os2.h file similar to windows.h file
|
||||
*/
|
||||
|
||||
#ifndef _nsFontMetricsOS2_h
|
||||
#define _nsFontMetricsOS2_h
|
||||
|
||||
#include "nsGfxDefs.h"
|
||||
|
||||
#include "plhash.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIFontEnumerator.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsString.h"
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDeviceContextOS2.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsDrawingSurfaceOS2.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
#ifndef FM_DEFN_LATIN1
|
||||
#define FM_DEFN_LATIN1 0x0010 /* Base latin character set */
|
||||
#define FM_DEFN_PC 0x0020 /* PC characters */
|
||||
#define FM_DEFN_LATIN2 0x0040 /* Extended latin character set */
|
||||
#define FM_DEFN_CYRILLIC 0x0080 /* Cyrillic character set */
|
||||
#define FM_DEFN_HEBREW 0x0100 /* Base Hebrew characters */
|
||||
#define FM_DEFN_GREEK 0x0200 /* Base Greek characters */
|
||||
#define FM_DEFN_ARABIC 0x0400 /* Base Arabic characters */
|
||||
#define FM_DEFN_UGLEXT 0x0800 /* Additional UGL chars */
|
||||
#define FM_DEFN_KANA 0x1000 /* Katakana and hiragana chars */
|
||||
#define FM_DEFN_THAI 0x2000 /* Thai characters */
|
||||
|
||||
#define FM_DEFN_UGL383 0x0070 /* Chars in OS/2 2.1 */
|
||||
#define FM_DEFN_UGL504 0x00F0 /* Chars in OS/2 Warp 4 */
|
||||
#define FM_DEFN_UGL767 0x0FF0 /* Chars in ATM fonts */
|
||||
#define FM_DEFN_UGL1105 0x3FF0 /* Chars in bitmap fonts */
|
||||
#endif
|
||||
|
||||
// Debug defines
|
||||
//#define DEBUG_FONT_SELECTION
|
||||
//#define DEBUG_FONT_STRUCT_ALLOCS
|
||||
|
||||
#define USE_FREETYPE
|
||||
|
||||
#ifdef USE_FREETYPE
|
||||
#define PERF_HASGLYPH_CHAR_MAP
|
||||
#define USE_EXPANDED_FREETYPE_FUNCS
|
||||
#endif
|
||||
|
||||
struct nsMiniMetrics
|
||||
{
|
||||
char szFacename[FACESIZE];
|
||||
USHORT fsType;
|
||||
USHORT fsDefn;
|
||||
USHORT fsSelection;
|
||||
nsMiniMetrics* mNext;
|
||||
};
|
||||
|
||||
// GlobalFontEntry->mStr is an nsString which contains the family name of font.
|
||||
class GlobalFontEntry : public nsStringHashKey
|
||||
{
|
||||
public:
|
||||
GlobalFontEntry(KeyTypePointer aStr) : nsStringHashKey(aStr) { }
|
||||
GlobalFontEntry(const GlobalFontEntry& aToCopy)
|
||||
: nsStringHashKey(aToCopy) { }
|
||||
~GlobalFontEntry()
|
||||
{
|
||||
nsMiniMetrics* metrics = mMetrics;
|
||||
while (metrics) {
|
||||
nsMiniMetrics* nextMetrics = metrics->mNext;
|
||||
if (metrics)
|
||||
delete metrics;
|
||||
metrics = nextMetrics;
|
||||
}
|
||||
#ifdef PERF_HASGLYPH_CHAR_MAP
|
||||
if (mHaveCheckedCharMap) {
|
||||
nsMemory::Free(mHaveCheckedCharMap);
|
||||
nsMemory::Free(mRepresentableCharMap);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Override, since we want to compare font names as case insensitive
|
||||
PRBool KeyEquals(const KeyTypePointer aKey) const
|
||||
{
|
||||
return GetKey().Equals(*aKey, nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
static PLDHashNumber HashKey(const KeyTypePointer aKey)
|
||||
{
|
||||
nsAutoString low(*aKey);
|
||||
ToLowerCase(low);
|
||||
return HashString(low);
|
||||
}
|
||||
|
||||
USHORT mCodePage;
|
||||
nsMiniMetrics* mMetrics;
|
||||
|
||||
#ifdef PERF_HASGLYPH_CHAR_MAP
|
||||
PRUint32* mHaveCheckedCharMap;
|
||||
PRUint32* mRepresentableCharMap;
|
||||
#endif
|
||||
};
|
||||
|
||||
// An nsFontHandle is actually a pointer to one of these.
|
||||
// It knows how to select itself into a ps.
|
||||
class nsFontOS2
|
||||
{
|
||||
public:
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
nsFontOS2(void);
|
||||
virtual ~nsFontOS2(void);
|
||||
|
||||
inline void SelectIntoPS(HPS hps, long lcid);
|
||||
virtual PRBool HasGlyph(HPS aPS, PRUint32 aChar) { return PR_TRUE; };
|
||||
virtual PRInt32 GetWidth(HPS aPS, const char* aString, PRUint32 aLength);
|
||||
virtual PRInt32 GetWidth(HPS aPS, const PRUnichar* aString, PRUint32 aLength);
|
||||
virtual void DrawString(HPS aPS, nsDrawingSurfaceOS2* aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
const char* aString, PRUint32 aLength, INT* aDx0);
|
||||
virtual void DrawString(HPS aPS, nsDrawingSurfaceOS2* aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
|
||||
FATTRS mFattrs;
|
||||
SIZEF mCharbox;
|
||||
ULONG mHashMe;
|
||||
nscoord mMaxAscent;
|
||||
nscoord mMaxDescent;
|
||||
int mConvertCodePage; /* XXX do we need this, or is it just a copy of mFattrs.usCodePage */
|
||||
#ifdef DEBUG_FONT_STRUCT_ALLOCS
|
||||
static unsigned long mRefCount;
|
||||
#endif
|
||||
|
||||
#ifdef PERF_HASGLYPH_CHAR_MAP
|
||||
PRUint32* mHaveCheckedCharMap;
|
||||
PRUint32* mRepresentableCharMap;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* nsFontSwitchCallback
|
||||
*
|
||||
* Font-switching callback function. Used by ResolveForwards() and
|
||||
* ResolveBackwards(). aFontSwitch points to a structure that gives
|
||||
* details about the current font needed to represent the current
|
||||
* substring. In particular, this struct contains a handler to the font
|
||||
* and some metrics of the font. These metrics may be different from
|
||||
* the metrics obtained via nsIFontMetrics.
|
||||
* Return PR_FALSE to stop the resolution of the remaining substrings.
|
||||
*/
|
||||
|
||||
struct nsFontSwitch {
|
||||
// Simple wrapper on top of nsFontOS2 for the moment
|
||||
// Could hold other attributes of the font
|
||||
nsFontOS2* mFont;
|
||||
};
|
||||
|
||||
typedef PRBool (*PR_CALLBACK nsFontSwitchCallback)
|
||||
(const nsFontSwitch* aFontSwitch,
|
||||
const PRUnichar* aSubstring,
|
||||
PRUint32 aSubstringLength,
|
||||
void* aData);
|
||||
|
||||
|
||||
class nsFontMetricsOS2 : public nsIFontMetrics
|
||||
{
|
||||
public:
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsFontMetricsOS2();
|
||||
virtual ~nsFontMetricsOS2();
|
||||
|
||||
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIDeviceContext* aContext);
|
||||
NS_IMETHOD Destroy();
|
||||
|
||||
NS_IMETHOD GetXHeight(nscoord& aResult);
|
||||
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
|
||||
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
|
||||
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
|
||||
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
|
||||
NS_IMETHOD GetHeight(nscoord& aHeight);
|
||||
#ifdef FONT_LEADING_APIS_V2
|
||||
NS_IMETHOD GetInternalLeading(nscoord &aLeading);
|
||||
NS_IMETHOD GetExternalLeading(nscoord &aLeading);
|
||||
#else
|
||||
NS_IMETHOD GetLeading(nscoord &aLeading);
|
||||
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight);
|
||||
#endif //FONT_LEADING_APIS_V2
|
||||
NS_IMETHOD GetEmHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetEmAscent(nscoord &aAscent);
|
||||
NS_IMETHOD GetEmDescent(nscoord &aDescent);
|
||||
NS_IMETHOD GetMaxHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
|
||||
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
|
||||
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
|
||||
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
|
||||
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
|
||||
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
|
||||
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
|
||||
// No known string length limits on OS/2
|
||||
virtual PRInt32 GetMaxStringLength() { return PR_INT32_MAX; }
|
||||
|
||||
virtual nsresult
|
||||
ResolveForwards(HPS aPS,
|
||||
const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
nsFontSwitchCallback aFunc,
|
||||
void* aData);
|
||||
|
||||
virtual nsresult
|
||||
ResolveBackwards(HPS aPS,
|
||||
const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
nsFontSwitchCallback aFunc,
|
||||
void* aData);
|
||||
|
||||
nsFontOS2* FindFont(HPS aPS, PRUint32 aChar);
|
||||
nsFontOS2* FindUserDefinedFont(HPS aPS, PRUint32 aChar);
|
||||
nsFontOS2* FindLocalFont(HPS aPS, PRUint32 aChar);
|
||||
nsFontOS2* FindGenericFont(HPS aPS, PRUint32 aChar);
|
||||
virtual nsFontOS2* FindPrefFont(HPS aPS, PRUint32 aChar);
|
||||
virtual nsFontOS2* FindGlobalFont(HPS aPS, PRUint32 aChar);
|
||||
#ifdef USE_FREETYPE
|
||||
virtual nsFontOS2* FindSubstituteFont(HPS aPS, PRUint32 aChar)
|
||||
{ return nsnull; };
|
||||
#endif
|
||||
|
||||
nsFontOS2* LoadFont(HPS aPS, const nsAString& aName);
|
||||
nsFontOS2* LoadGenericFont(HPS aPS, PRUint32 aChar, const nsAString& aName);
|
||||
nsFontOS2* LoadUnicodeFont(HPS aPS, const nsAString& aName);
|
||||
static nsresult InitializeGlobalFonts();
|
||||
|
||||
static nsTHashtable<GlobalFontEntry>* gGlobalFonts;
|
||||
static PLHashTable* gFamilyNames;
|
||||
static PRBool gSubstituteVectorFonts;
|
||||
#ifdef USE_FREETYPE
|
||||
static PRBool gUseFTFunctions;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIAtom> mLangGroup;
|
||||
nsStringArray mFonts;
|
||||
PRInt32 mFontsIndex;
|
||||
nsVoidArray mLoadedFonts;
|
||||
nsFontOS2* mUnicodeFont;
|
||||
nsFontOS2* mWesternFont;
|
||||
|
||||
PRInt32 mGenericIndex;
|
||||
nsString mGeneric;
|
||||
nsString mUserDefined;
|
||||
|
||||
PRBool mTriedAllGenerics;
|
||||
PRBool mTriedAllPref;
|
||||
PRBool mIsUserDefined;
|
||||
|
||||
int mConvertCodePage;
|
||||
|
||||
protected:
|
||||
nsresult RealizeFont(void);
|
||||
PRBool GetVectorSubstitute(HPS aPS, const nsAString& aFacename,
|
||||
nsAString& aAlias);
|
||||
void FindUnicodeFont(HPS aPS);
|
||||
void FindWesternFont();
|
||||
nsFontOS2* SetFontHandle(HPS aPS, GlobalFontEntry* aEntry,
|
||||
nsMiniMetrics* aMetrics, PRBool aDoFakeEffects);
|
||||
PLHashTable* InitializeFamilyNames(void);
|
||||
|
||||
nscoord mSuperscriptYOffset;
|
||||
nscoord mSubscriptYOffset;
|
||||
nscoord mStrikeoutPosition;
|
||||
nscoord mStrikeoutSize;
|
||||
nscoord mUnderlinePosition;
|
||||
nscoord mUnderlineSize;
|
||||
nscoord mExternalLeading;
|
||||
nscoord mInternalLeading;
|
||||
nscoord mEmHeight;
|
||||
nscoord mEmAscent;
|
||||
nscoord mEmDescent;
|
||||
nscoord mMaxHeight;
|
||||
nscoord mMaxAscent;
|
||||
nscoord mMaxDescent;
|
||||
nscoord mMaxAdvance;
|
||||
nscoord mSpaceWidth;
|
||||
nscoord mXHeight;
|
||||
nscoord mAveCharWidth;
|
||||
|
||||
nsFontOS2 *mFontHandle;
|
||||
nsDeviceContextOS2 *mDeviceContext;
|
||||
|
||||
#ifdef DEBUG_FONT_STRUCT_ALLOCS
|
||||
static unsigned long mRefCount;
|
||||
#endif
|
||||
};
|
||||
|
||||
class nsFontEnumeratorOS2 : public nsIFontEnumerator
|
||||
{
|
||||
public:
|
||||
nsFontEnumeratorOS2();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFONTENUMERATOR
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#ifdef USE_FREETYPE
|
||||
typedef BOOL (APIENTRY * Ft2EnableFontEngine) (BOOL fEnable);
|
||||
|
||||
class nsFontMetricsOS2FT : public nsFontMetricsOS2
|
||||
{
|
||||
public:
|
||||
virtual ~nsFontMetricsOS2FT();
|
||||
|
||||
virtual nsresult
|
||||
ResolveForwards(HPS aPS,
|
||||
const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
nsFontSwitchCallback aFunc,
|
||||
void* aData);
|
||||
|
||||
virtual nsresult
|
||||
ResolveBackwards(HPS aPS,
|
||||
const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
nsFontSwitchCallback aFunc,
|
||||
void* aData);
|
||||
|
||||
virtual nsFontOS2* FindPrefFont(HPS aPS, PRUint32 aChar);
|
||||
virtual nsFontOS2* FindGlobalFont(HPS aPS, PRUint32 aChar);
|
||||
virtual nsFontOS2* FindSubstituteFont(HPS aPS, PRUint32 aChar);
|
||||
|
||||
static Ft2EnableFontEngine pfnFt2EnableFontEngine;
|
||||
|
||||
nsFontOS2* mSubstituteFont;
|
||||
|
||||
protected:
|
||||
nsFontOS2* LocateFont(HPS aPS, PRUint32 aChar, PRInt32 & aCount);
|
||||
};
|
||||
|
||||
typedef BOOL (APIENTRY * Ft2FontSupportsUnicodeChar1) (PSTR8 pName,
|
||||
PFATTRS pfatAttrs,
|
||||
BOOL isUnicode,
|
||||
UniChar ch);
|
||||
#ifdef USE_EXPANDED_FREETYPE_FUNCS
|
||||
typedef USHORT *LPWSTR;
|
||||
typedef BOOL (APIENTRY * Ft2QueryTextBoxW) (HPS hps, LONG lCount1,
|
||||
LPWSTR pchString,LONG lCount2,
|
||||
PPOINTL aptlPoints);
|
||||
typedef LONG (APIENTRY * Ft2CharStringPosAtW) (HPS hps, PPOINTL pptlStart,
|
||||
PRECTL prclRect, ULONG flOptions,
|
||||
LONG lCount, LPWSTR pchString,
|
||||
PLONG alAdx, ULONG fuWin32Options);
|
||||
#endif /* use_expanded_freetype_funcs */
|
||||
|
||||
|
||||
class nsFontOS2FT : public nsFontOS2
|
||||
{
|
||||
public:
|
||||
nsFontOS2FT(void);
|
||||
virtual ~nsFontOS2FT(void);
|
||||
|
||||
virtual PRBool HasGlyph(HPS aPS, PRUint32 aChar);
|
||||
|
||||
using nsFontOS2::GetWidth;
|
||||
using nsFontOS2::DrawString;
|
||||
virtual PRInt32 GetWidth(HPS aPS, const PRUnichar* aString, PRUint32 aLength);
|
||||
virtual void DrawString(HPS aPS, nsDrawingSurfaceOS2* aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
|
||||
PRBool IsSymbolFont() { return mFattrs.usCodePage == 65400; };
|
||||
|
||||
static Ft2FontSupportsUnicodeChar1 pfnFt2FontSupportsUnicodeChar1;
|
||||
#ifdef USE_EXPANDED_FREETYPE_FUNCS
|
||||
static Ft2QueryTextBoxW pfnFt2QueryTextBoxW;
|
||||
static Ft2CharStringPosAtW pfnFt2CharStringPosAtW;
|
||||
#endif /* use_expanded_freetype_funcs */
|
||||
#ifdef DEBUG_FONT_STRUCT_ALLOCS
|
||||
static unsigned long mRefCount;
|
||||
#endif
|
||||
};
|
||||
|
||||
// A "substitute font" to deal with missing glyphs -- see bug 6585
|
||||
// We now use transliteration+fallback to the REPLACEMENT CHAR +
|
||||
// HEX representation to handle this issue.
|
||||
class nsFontOS2Substitute : public nsFontOS2
|
||||
{
|
||||
public:
|
||||
nsFontOS2Substitute(nsFontOS2* aFont);
|
||||
virtual ~nsFontOS2Substitute(void);
|
||||
|
||||
virtual PRBool HasGlyph(HPS aPS, PRUint32 ch)
|
||||
{ return !IS_IN_BMP(ch) || IS_REPRESENTABLE(mRepresentableCharMap, ch); };
|
||||
virtual void SetRepresentable(PRUint32 ch)
|
||||
{ if (IS_IN_BMP(ch)) SET_REPRESENTABLE(mRepresentableCharMap, ch); };
|
||||
|
||||
using nsFontOS2::GetWidth;
|
||||
using nsFontOS2::DrawString;
|
||||
virtual PRInt32 GetWidth(HPS aPS, const PRUnichar* aString, PRUint32 aLength);
|
||||
virtual void DrawString(HPS aPS, nsDrawingSurfaceOS2* aSurface,
|
||||
PRInt32 aX, PRInt32 aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
|
||||
private:
|
||||
//We need to have a easily operatable charmap for substitute font
|
||||
PRUint32 mRepresentableCharMap[UCS2_MAP_LEN];
|
||||
};
|
||||
#endif /* use_freetype */
|
||||
|
||||
#endif
|
@ -1,179 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* 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 ***** */
|
||||
|
||||
#include "nsGfxDefs.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
//DJ #include "nsLog.h"
|
||||
//DJ NS_IMPL_LOG_ENABLED (GFXLog)
|
||||
//DJ #define DPRINTF NS_LOG_PRINTF(GFXLog)
|
||||
#include <stdio.h>
|
||||
#define DPRINTF printf
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define DPRINTF printf
|
||||
#endif
|
||||
|
||||
#include "nsDeviceContextSpecOS2.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
BOOL GetTextExtentPoint32(HPS aPS, const char* aString, int aLength, PSIZEL aSizeL)
|
||||
{
|
||||
BOOL rc = TRUE;
|
||||
POINTL ptls[5];
|
||||
|
||||
aSizeL->cx = 0;
|
||||
|
||||
while(aLength > 0 && rc == TRUE) {
|
||||
ULONG thislen = min(aLength, 512);
|
||||
rc = GFX (::GpiQueryTextBox(aPS, thislen, (PCH)aString, 5, ptls), FALSE);
|
||||
aSizeL->cx += ptls[TXTBOX_CONCAT].x;
|
||||
aLength -= thislen;
|
||||
aString += thislen;
|
||||
}
|
||||
|
||||
aSizeL->cy = ptls[TXTBOX_TOPLEFT].y - ptls[TXTBOX_BOTTOMLEFT].y;
|
||||
return rc;
|
||||
}
|
||||
|
||||
BOOL ExtTextOut(HPS aPS, int X, int Y, UINT fuOptions, const RECTL* lprc,
|
||||
const char* aString, unsigned int aLength, const int* pSpacing)
|
||||
{
|
||||
long rc = GPI_OK;
|
||||
POINTL ptl = {X, Y};
|
||||
|
||||
GFX (::GpiMove(aPS, &ptl), FALSE);
|
||||
|
||||
// GpiCharString has a max length of 512 chars at a time...
|
||||
while (aLength > 0 && rc == GPI_OK) {
|
||||
ULONG ulChunkLen = min(aLength, 512);
|
||||
if (pSpacing) {
|
||||
rc = GFX (::GpiCharStringPos(aPS, nsnull, CHS_VECTOR, ulChunkLen,
|
||||
(PCH)aString, (PLONG)pSpacing), GPI_ERROR);
|
||||
pSpacing += ulChunkLen;
|
||||
} else {
|
||||
rc = GFX (::GpiCharString(aPS, ulChunkLen, (PCH)aString), GPI_ERROR);
|
||||
}
|
||||
aLength -= ulChunkLen;
|
||||
aString += ulChunkLen;
|
||||
}
|
||||
|
||||
if (rc == GPI_OK)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL bIsDBCS;
|
||||
static BOOL bIsDBCSSet = FALSE;
|
||||
|
||||
BOOL IsDBCS()
|
||||
{
|
||||
if (!bIsDBCSSet) {
|
||||
// the following lines of code determine whether the system is a DBCS country
|
||||
APIRET rc;
|
||||
COUNTRYCODE ctrycodeInfo = {0};
|
||||
CHAR achDBCSInfo[12] = {0}; // DBCS environmental vector
|
||||
ctrycodeInfo.country = 0; // current country
|
||||
ctrycodeInfo.codepage = 0; // current codepage
|
||||
|
||||
rc = DosQueryDBCSEnv(sizeof(achDBCSInfo), &ctrycodeInfo, achDBCSInfo);
|
||||
if (rc == NO_ERROR)
|
||||
{
|
||||
// NON-DBCS countries will have four bytes in the first four bytes of the
|
||||
// DBCS environmental vector
|
||||
if (achDBCSInfo[0] != 0 || achDBCSInfo[1] != 0 ||
|
||||
achDBCSInfo[2] != 0 || achDBCSInfo[3] != 0)
|
||||
{
|
||||
bIsDBCS = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bIsDBCS = FALSE;
|
||||
}
|
||||
} else {
|
||||
bIsDBCS = FALSE;
|
||||
} /* endif */
|
||||
bIsDBCSSet = TRUE;
|
||||
} /* endif */
|
||||
return bIsDBCS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Module-level data ---------------------------------------------------------
|
||||
#ifdef DEBUG
|
||||
void DEBUG_LogErr(long ReturnCode, const char* ErrorExpression,
|
||||
const char* FileName, const char* FunctionName, long LineNum)
|
||||
{
|
||||
char TempBuf [300];
|
||||
|
||||
strcpy (TempBuf, ErrorExpression);
|
||||
char* APIName = TempBuf;
|
||||
|
||||
char* ch = strstr (APIName , "("); // Find start of function parameter list
|
||||
if (ch != NULL) // Opening parenthesis found - it is a function
|
||||
{
|
||||
while (isspace (*--ch)) {} // Remove whitespaces before opening parenthesis
|
||||
*++ch = '\0';
|
||||
|
||||
if (APIName [0] == ':' && APIName [1] == ':') // Remove global scope operator
|
||||
APIName += 2;
|
||||
|
||||
while (isspace (*APIName)) // Remove spaces before function name
|
||||
APIName++;
|
||||
}
|
||||
|
||||
|
||||
USHORT ErrorCode = ERRORIDERROR (::WinGetLastError(0));
|
||||
|
||||
printf("GFX_Err: %s = 0x%X, 0x%X (%s - %s, line %ld)\n", APIName, ReturnCode,
|
||||
ErrorCode, FileName, FunctionName, LineNum);
|
||||
}
|
||||
#endif
|
||||
|
||||
void PMERROR( const char *api)
|
||||
{
|
||||
ERRORID eid = ::WinGetLastError(0);
|
||||
USHORT usError = ERRORIDERROR(eid);
|
||||
DPRINTF ( "%s failed, error = 0x%X\n", api, usError);
|
||||
}
|
||||
|
@ -1,125 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* 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 _nsgfxdefs_h
|
||||
#define _nsgfxdefs_h
|
||||
|
||||
// nsGfxDefs.h - common includes etc. for gfx library
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#define INCL_PM
|
||||
#define INCL_DOS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_DEV
|
||||
#include <os2.h>
|
||||
#include "prlog.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
#include <uconv.h> // XXX hack XXX
|
||||
|
||||
#define COLOR_CUBE_SIZE 216
|
||||
|
||||
void PMERROR(const char *str);
|
||||
|
||||
// Wrapper code for all OS/2 system calls to check the return code for error condition in debug build.
|
||||
// Could be used like this:
|
||||
//
|
||||
// HDC hdc = GFX (::GpiQueryDevice (ps), HDC_ERROR);
|
||||
// GFX (::GpiAssociate (mPrintPS, 0), FALSE);
|
||||
// return GFX (::GpiDestroyPS (mPrintPS), FALSE);
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void DEBUG_LogErr(long ReturnCode, const char* ErrorExpression,
|
||||
const char* FileName, const char* FunctionName,
|
||||
long LineNum);
|
||||
|
||||
inline long CheckSuccess(long ReturnCode, long SuccessCode,
|
||||
const char* ErrorExpression, const char* FileName,
|
||||
const char* FunctionName, long LineNum)
|
||||
{
|
||||
if (ReturnCode != SuccessCode) {
|
||||
DEBUG_LogErr(ReturnCode, ErrorExpression, FileName, FunctionName, LineNum);
|
||||
}
|
||||
return ReturnCode;
|
||||
}
|
||||
|
||||
#define CHK_SUCCESS(ReturnCode, SuccessCode) \
|
||||
CheckSuccess(ReturnCode, SuccessCode, #ReturnCode, __FILE__, \
|
||||
__FUNCTION__, __LINE__)
|
||||
|
||||
inline long CheckFailure(long ReturnCode, long ErrorCode,
|
||||
const char* ErrorExpression, const char* FileName,
|
||||
const char* FunctionName, long LineNum)
|
||||
{
|
||||
if (ReturnCode == ErrorCode) {
|
||||
DEBUG_LogErr(ReturnCode, ErrorExpression, FileName, FunctionName, LineNum);
|
||||
}
|
||||
return ReturnCode;
|
||||
}
|
||||
|
||||
/* #define CHK_FAIL(ReturnCode, ErrorCode) \ */
|
||||
#define GFX(ReturnCode, ErrorCode) \
|
||||
CheckFailure(ReturnCode, ErrorCode, #ReturnCode, __FILE__, \
|
||||
__FUNCTION__, __LINE__)
|
||||
|
||||
#else // Retail build
|
||||
#define CHK_SUCCESS(ReturnCode, SuccessCode) ReturnCode
|
||||
/* #define CHK_FAIL(ReturnCode, ErrorCode) ReturnCode */
|
||||
#define GFX(ReturnCode, ErrorCode) ReturnCode
|
||||
#endif
|
||||
|
||||
class nsString;
|
||||
class nsIDeviceContext;
|
||||
|
||||
|
||||
BOOL GetTextExtentPoint32(HPS aPS, const char* aString, int aLength, PSIZEL aSizeL);
|
||||
BOOL ExtTextOut(HPS aPS, int X, int Y, UINT fuOptions, const RECTL* lprc,
|
||||
const char* aString, unsigned int aLength, const int* pDx);
|
||||
|
||||
BOOL IsDBCS();
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define MK_RGB(r,g,b) ((r) * 65536) + ((g) * 256) + (b)
|
||||
|
||||
#ifdef DEBUG
|
||||
extern PRLogModuleInfo *gGFXOS2LogModule;
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,327 +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
|
||||
* Christopher Blizzard.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzzard <blizzard@mozilla.org>
|
||||
*
|
||||
* 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 "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "nsBlender.h"
|
||||
#include "nsFontMetricsOS2.h"
|
||||
#include "nsRenderingContextOS2.h"
|
||||
#include "nsScriptableRegion.h"
|
||||
#include "nsDeviceContextOS2.h"
|
||||
#include "nsImageOS2.h"
|
||||
#include "nsRegionOS2.h"
|
||||
#include "gfxImageFrame.h"
|
||||
#include "nsFontList.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "prenv.h"
|
||||
#include "nsOS2Uni.h"
|
||||
#include "nsPaletteOS2.h"
|
||||
|
||||
// objects that just require generic constructors
|
||||
|
||||
#if !defined(USE_FREETYPE)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsOS2)
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextOS2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextOS2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageOS2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionOS2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorOS2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
|
||||
|
||||
#ifdef USE_FREETYPE
|
||||
// Can't include os2win.h, since it screws things up. So definitions go here.
|
||||
typedef ULONG HKEY;
|
||||
#define HKEY_LOCAL_MACHINE 0xFFFFFFEFL
|
||||
#define HKEY_CURRENT_USER 0xFFFFFFEEL
|
||||
#define READ_CONTROL 0x00020000
|
||||
#define KEY_QUERY_VALUE 0x0001
|
||||
#define KEY_ENUMERATE_SUB_KEYS 0x0008
|
||||
#define KEY_NOTIFY 0x0010
|
||||
#define KEY_READ READ_CONTROL | KEY_QUERY_VALUE | \
|
||||
KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
|
||||
#define ERROR_SUCCESS 0L
|
||||
|
||||
static PRBool
|
||||
UseFTFunctions()
|
||||
{
|
||||
static PRBool init = PR_FALSE;
|
||||
if (!init) {
|
||||
init = PR_TRUE;
|
||||
|
||||
// For now, since this is somewhat experimental, we'll check for an
|
||||
// environment variable, rather than making this the default for anyone
|
||||
// that uses the FT2LIB.
|
||||
char* useFT = PR_GetEnv("MOZILLA_USE_EXTENDED_FT2LIB");
|
||||
if (useFT == nsnull || *useFT == '\0' || stricmp(useFT, "t") != 0) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Test for availability of registry functions and query their addresses
|
||||
APIRET rc;
|
||||
HMODULE hmod = NULLHANDLE;
|
||||
char LoadError[CCHMAXPATH];
|
||||
rc = DosLoadModule(LoadError, CCHMAXPATH, "REGISTRY", &hmod);
|
||||
if (rc != NO_ERROR) {
|
||||
NS_WARNING("REGISTRY.DLL could not be loaded");
|
||||
return PR_FALSE;
|
||||
}
|
||||
LONG _System (*APIENTRY RegOpenKeyEx)(HKEY, const char*, ULONG, ULONG,
|
||||
HKEY* );
|
||||
LONG _System (*APIENTRY RegQueryValueEx)(HKEY, const char*, ULONG*, ULONG*,
|
||||
UCHAR*, ULONG*);
|
||||
|
||||
rc = DosQueryProcAddr(hmod, 0L, "RegOpenKeyExA", (PFN*)&RegOpenKeyEx);
|
||||
rc += DosQueryProcAddr(hmod, 0L, "RegQueryValueExA", (PFN*)&RegQueryValueEx);
|
||||
if (rc != NO_ERROR) {
|
||||
NS_WARNING("Registry function(s) were not found in REGISTRY.DLL");
|
||||
DosFreeModule(hmod);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Is FT2LIB enabled?
|
||||
HKEY key;
|
||||
LONG result = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
"Software\\Innotek\\InnoTek Font Engine", 0,
|
||||
KEY_READ, &key);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Innotek\\InnoTek Font Engine", 0,
|
||||
KEY_READ, &key);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
DosFreeModule(hmod);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG value;
|
||||
ULONG length = sizeof(value);
|
||||
result = RegQueryValueEx(key, "Enabled", NULL, NULL, (UCHAR*)&value,
|
||||
&length);
|
||||
if (result != ERROR_SUCCESS || value == 0) {
|
||||
// check if "Innotek Font Engine" is disabled (value == 0)
|
||||
DosFreeModule(hmod);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Is FT2LIB enabled for this app?
|
||||
PPIB ppib;
|
||||
PTIB ptib;
|
||||
char buffer[CCHMAXPATH], name[_MAX_FNAME], ext[_MAX_EXT], keystr[256];
|
||||
DosGetInfoBlocks(&ptib, &ppib);
|
||||
DosQueryModuleName(ppib->pib_hmte, CCHMAXPATH, buffer);
|
||||
_splitpath(buffer, NULL, NULL, name, ext);
|
||||
strcpy(keystr, "Software\\Innotek\\InnoTek Font Engine\\Applications\\");
|
||||
strcat(keystr, name);
|
||||
strcat(keystr, ext);
|
||||
result = RegOpenKeyEx(HKEY_CURRENT_USER, keystr, 0, KEY_READ, &key);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keystr, 0, KEY_READ, &key);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
DosFreeModule(hmod);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
result = RegQueryValueEx(key, "Enabled", NULL, NULL, (UCHAR*)&value,
|
||||
&length);
|
||||
if (result != ERROR_SUCCESS || value == 0) {
|
||||
// check if FT2LIB is disabled for our application (value == 0)
|
||||
DosFreeModule(hmod);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// REGISTRY.DLL use ends here
|
||||
DosFreeModule(hmod);
|
||||
|
||||
// Load lib and functions
|
||||
rc = DosLoadModule(LoadError, 0, "FT2LIB", &hmod);
|
||||
if (rc == NO_ERROR) {
|
||||
rc = DosQueryProcAddr(hmod, 0, "Ft2EnableFontEngine",
|
||||
(PFN*)&nsFontMetricsOS2FT::pfnFt2EnableFontEngine);
|
||||
if (rc == NO_ERROR) {
|
||||
DosQueryProcAddr(hmod, 0, "Ft2FontSupportsUnicodeChar1",
|
||||
(PFN*)&nsFontOS2FT::pfnFt2FontSupportsUnicodeChar1);
|
||||
#ifdef USE_EXPANDED_FREETYPE_FUNCS
|
||||
DosQueryProcAddr(hmod, 0, "Ft2QueryTextBoxW",
|
||||
(PFN*)&nsFontOS2FT::pfnFt2QueryTextBoxW);
|
||||
DosQueryProcAddr(hmod, 0, "Ft2CharStringPosAtW",
|
||||
(PFN*)&nsFontOS2FT::pfnFt2CharStringPosAtW);
|
||||
#endif /* use_expanded_freetype_funcs */
|
||||
NS_WARNING("*** Now using Freetype functions ***");
|
||||
nsFontMetricsOS2::gUseFTFunctions = PR_TRUE;
|
||||
}
|
||||
DosFreeModule(hmod);
|
||||
}
|
||||
}
|
||||
return nsFontMetricsOS2::gUseFTFunctions;
|
||||
}
|
||||
|
||||
static NS_IMETHODIMP
|
||||
nsFontMetricsOS2Constructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsFontMetricsOS2* result;
|
||||
if (UseFTFunctions())
|
||||
result = new nsFontMetricsOS2FT();
|
||||
else
|
||||
result = new nsFontMetricsOS2();
|
||||
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
NS_ADDREF(result);
|
||||
rv = result->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(result);
|
||||
return rv;
|
||||
}
|
||||
#endif /* use_freetype */
|
||||
|
||||
static NS_IMETHODIMP
|
||||
nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIScriptableRegion *inst = NULL;
|
||||
|
||||
if ( !aResult )
|
||||
{
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = nsnull;
|
||||
if (aOuter)
|
||||
{
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
// create an nsRegionOS2 and get the scriptable region from it
|
||||
nsCOMPtr <nsIRegion> rgn;
|
||||
NS_NEWXPCOM(rgn, nsRegionOS2);
|
||||
nsCOMPtr<nsIScriptableRegion> scriptableRgn;
|
||||
if (rgn != nsnull)
|
||||
{
|
||||
scriptableRgn = new nsScriptableRegion(rgn);
|
||||
inst = scriptableRgn;
|
||||
}
|
||||
if (!inst)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(inst);
|
||||
// release our variable above now that we have created our owning
|
||||
// reference - we don't want this to go out of scope early!
|
||||
scriptableRgn = nsnull;
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(inst);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "OS/2 Font Metrics",
|
||||
NS_FONT_METRICS_CID,
|
||||
// "@mozilla.org/gfx/font_metrics/gtk;1",
|
||||
"@mozilla.org/gfx/fontmetrics;1",
|
||||
nsFontMetricsOS2Constructor },
|
||||
{ "OS/2 Device Context",
|
||||
NS_DEVICE_CONTEXT_CID,
|
||||
// "@mozilla.org/gfx/device_context/gtk;1",
|
||||
"@mozilla.org/gfx/devicecontext;1",
|
||||
nsDeviceContextOS2Constructor },
|
||||
{ "OS/2 Rendering Context",
|
||||
NS_RENDERING_CONTEXT_CID,
|
||||
// "@mozilla.org/gfx/rendering_context/gtk;1",
|
||||
"@mozilla.org/gfx/renderingcontext;1",
|
||||
nsRenderingContextOS2Constructor },
|
||||
{ "OS/2 Image",
|
||||
NS_IMAGE_CID,
|
||||
// "@mozilla.org/gfx/image/gtk;1",
|
||||
"@mozilla.org/gfx/image;1",
|
||||
nsImageOS2Constructor },
|
||||
{ "OS/2 Region",
|
||||
NS_REGION_CID,
|
||||
"@mozilla.org/gfx/region/gtk;1",
|
||||
nsRegionOS2Constructor },
|
||||
{ "Scriptable Region",
|
||||
NS_SCRIPTABLE_REGION_CID,
|
||||
// "@mozilla.org/gfx/scriptable_region;1",
|
||||
"@mozilla.org/gfx/region;1",
|
||||
nsScriptableRegionConstructor },
|
||||
{ "Blender",
|
||||
NS_BLENDER_CID,
|
||||
// "@mozilla.org/gfx/blender;1",
|
||||
"@mozilla.org/gfx/blender;1",
|
||||
nsBlenderConstructor },
|
||||
{ "OS2 Font Enumerator",
|
||||
NS_FONT_ENUMERATOR_CID,
|
||||
// "@mozilla.org/gfx/font_enumerator/gtk;1",
|
||||
"@mozilla.org/gfx/fontenumerator;1",
|
||||
nsFontEnumeratorOS2Constructor },
|
||||
{ "Font List",
|
||||
NS_FONTLIST_CID,
|
||||
// "@mozilla.org/gfx/fontlist;1"
|
||||
NS_FONTLIST_CONTRACTID,
|
||||
nsFontListConstructor },
|
||||
{ "windows image frame",
|
||||
GFX_IMAGEFRAME_CID,
|
||||
"@mozilla.org/gfx/image/frame;2",
|
||||
gfxImageFrameConstructor, },
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
nsGfxOS2ModuleDtor(nsIModule *self)
|
||||
{
|
||||
OS2Uni::FreeUconvObjects();
|
||||
nsPaletteOS2::FreeGlobalPalette();
|
||||
// nsRenderingContextOS2::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_DTOR(nsGfxOS2Module, components, nsGfxOS2ModuleDtor)
|
||||
|
@ -1,66 +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 nsIRenderingContextOS2_h___
|
||||
#define nsIRenderingContextOS2_h___
|
||||
|
||||
#include "nsIRenderingContext.h"
|
||||
#include <os2.h>
|
||||
|
||||
// IID for the nsIRenderingContext interface
|
||||
#define NS_IRENDERING_CONTEXT_OS2_IID \
|
||||
{ 0x0fcde820, 0x8ae2, 0x11d2, \
|
||||
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
// RenderingContextWin interface
|
||||
class nsIRenderingContextOS2 : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRENDERING_CONTEXT_OS2_IID)
|
||||
/**
|
||||
* Create a new drawing surface to represent an HPS.
|
||||
* @param aPS Windows HPS.
|
||||
* @param aSurface out parameter for new drawing surface
|
||||
* @result error status
|
||||
*/
|
||||
NS_IMETHOD CreateDrawingSurface(HPS aPS, nsIDrawingSurface* &aSurface, nsIWidget *aWidget) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRenderingContextOS2,
|
||||
NS_IRENDERING_CONTEXT_OS2_IID)
|
||||
|
||||
#endif /* nsIRenderingContextOS2_h___ */
|
File diff suppressed because it is too large
Load Diff
@ -1,218 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.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 *****
|
||||
*
|
||||
* 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_
|
||||
#define _nsImageOS2_h_
|
||||
|
||||
#include "nsIImage.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
struct nsDrawingSurfaceOS2;
|
||||
|
||||
class nsImageOS2 : public nsIImage{
|
||||
public:
|
||||
nsImageOS2();
|
||||
~nsImageOS2();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
@see nsIImage.h
|
||||
*/
|
||||
virtual PRInt32 GetBytesPix() { return mInfo ? (mInfo->cBitCount <= 8 ? 1 : mInfo->cBitCount / 8) : 0; }
|
||||
virtual PRInt32 GetHeight() { return mInfo ? mInfo->cy : 0; }
|
||||
virtual PRBool GetIsRowOrderTopToBottom() { return PR_FALSE; }
|
||||
virtual PRInt32 GetWidth() { return mInfo ? mInfo->cx : 0; }
|
||||
virtual PRUint8* GetBits() { return mImageBits; }
|
||||
virtual PRInt32 GetLineStride() { return mRowBytes; }
|
||||
|
||||
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
|
||||
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* 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 PRBool GetIsImageComplete();
|
||||
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
|
||||
virtual nsresult Optimize(nsIDeviceContext* aContext);
|
||||
virtual PRUint8* GetAlphaBits() { return mAlphaBits; }
|
||||
virtual PRInt32 GetAlphaLineStride(){ return mARowBytes; }
|
||||
|
||||
/**
|
||||
* Draw a tiled version of the bitmap
|
||||
* @param aSurface the surface to blit to
|
||||
* @param aSXOffset Offset from image's upper right corner that will be located at
|
||||
* @param aSYOffset upper right corner of filled area
|
||||
* @param aTileRect Area which must be filled with tiled image
|
||||
* @return if TRUE, no errors
|
||||
*/
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsIDrawingSurface* aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
PRInt32 aPadX, PRInt32 aPadY,
|
||||
const nsRect &aTileRect);
|
||||
|
||||
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
|
||||
nscoord aDWidth, nscoord 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
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
/**
|
||||
* Get the alpha depth for the image mask
|
||||
* @update - lordpixel 2001/05/16
|
||||
* @return the alpha mask depth for the image, ie, 0, 1 or 8
|
||||
*/
|
||||
virtual PRInt8 GetAlphaDepth() {return(mAlphaDepth);}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* 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);
|
||||
|
||||
void DrawComposited24(unsigned char *aBits,
|
||||
PRUint8 *aImageRGB, PRUint32 aStrideRGB,
|
||||
PRUint8 *aImageAlpha, PRUint32 aStrideAlpha,
|
||||
int aWidth, int aHeight);
|
||||
|
||||
#ifdef OS2TODO
|
||||
/**
|
||||
* 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(nsIDrawingSurface* 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;
|
||||
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
|
||||
|
||||
nsRect mDecodedRect; // Keeps track of what part of image has been decoded.
|
||||
|
||||
// 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
|
||||
|
||||
static PRUint8 gBlenderLookup [65536]; // Lookup table for fast alpha blending
|
||||
static PRBool gBlenderReady;
|
||||
static void BuildBlenderLookup (void);
|
||||
static PRUint8 FAST_BLEND (PRUint8 Source, PRUint8 Dest, PRUint8 Alpha) { return gBlenderLookup [(Alpha << 8) + Source] +
|
||||
gBlenderLookup [((255 - Alpha) << 8) + Dest]; }
|
||||
|
||||
NS_IMETHODIMP UpdateImageBits( HPS mPS );
|
||||
void NS2PM_ININ( const nsRect &in, RECTL &rcl);
|
||||
void CreateBitmaps( nsDrawingSurfaceOS2 *surf);
|
||||
|
||||
void BuildTile (HPS hpsTile, PRUint8* pImageBits, PBITMAPINFO2 pBitmapInfo, nscoord aTileWidth, nscoord aTileHeight, float scale);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,181 +0,0 @@
|
||||
/* ***** 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 an API for accessing OS/2 Unicode support.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 "nsOS2Uni.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/**********************************************************
|
||||
OS2Uni
|
||||
**********************************************************/
|
||||
nsICharsetConverterManager* OS2Uni::gCharsetManager = nsnull;
|
||||
|
||||
struct ConverterInfo
|
||||
{
|
||||
PRUint16 mCodePage;
|
||||
char* mConvName;
|
||||
nsIUnicodeEncoder* mEncoder;
|
||||
nsIUnicodeDecoder* mDecoder;
|
||||
};
|
||||
|
||||
#define eCONVERTER_COUNT 17
|
||||
ConverterInfo gConverterInfo[eCONVERTER_COUNT] =
|
||||
{
|
||||
{ 0, "", nsnull, nsnull },
|
||||
{ 1252, "windows-1252", nsnull, nsnull },
|
||||
{ 1208, "UTF-8", nsnull, nsnull },
|
||||
{ 1250, "windows-1250", nsnull, nsnull },
|
||||
{ 1251, "windows-1251", nsnull, nsnull },
|
||||
{ 813, "ISO-8859-7", nsnull, nsnull },
|
||||
{ 1254, "windows-1254", nsnull, nsnull },
|
||||
{ 864, "IBM864", nsnull, nsnull },
|
||||
{ 1257, "windows-1257", nsnull, nsnull },
|
||||
{ 874, "windows-874", nsnull, nsnull },
|
||||
{ 932, "Shift_JIS", nsnull, nsnull },
|
||||
{ 943, "Shift_JIS", nsnull, nsnull },
|
||||
{ 1381, "GB2312", nsnull, nsnull },
|
||||
{ 1386, "GB2312", nsnull, nsnull },
|
||||
{ 949, "x-windows-949", nsnull, nsnull },
|
||||
{ 950, "Big5", nsnull, nsnull },
|
||||
{ 1361, "x-johab", nsnull, nsnull }
|
||||
};
|
||||
|
||||
nsISupports*
|
||||
OS2Uni::GetUconvObject(int aCodePage, ConverterRequest aReq)
|
||||
{
|
||||
if (gCharsetManager == nsnull) {
|
||||
CallGetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &gCharsetManager);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsISupports* uco = nsnull;
|
||||
for (int i = 0; i < eCONVERTER_COUNT; i++) {
|
||||
if (aCodePage == gConverterInfo[i].mCodePage) {
|
||||
if (gConverterInfo[i].mEncoder == nsnull) {
|
||||
const char* convname;
|
||||
nsCAutoString charset;
|
||||
if (aCodePage == 0) {
|
||||
nsCOMPtr<nsIPlatformCharset>
|
||||
plat(do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
plat->GetCharset(kPlatformCharsetSel_FileName, charset);
|
||||
} else {
|
||||
// default to IBM850 if this should fail
|
||||
charset = "IBM850";
|
||||
}
|
||||
convname = charset.get();
|
||||
} else {
|
||||
convname = gConverterInfo[i].mConvName;
|
||||
}
|
||||
rv = gCharsetManager->GetUnicodeEncoderRaw(convname,
|
||||
&gConverterInfo[i].mEncoder);
|
||||
gConverterInfo[i].mEncoder->
|
||||
SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace,
|
||||
nsnull, '?');
|
||||
gCharsetManager->GetUnicodeDecoderRaw(convname,
|
||||
&gConverterInfo[i].mDecoder);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get converter");
|
||||
}
|
||||
if (aReq == eConv_Encoder) {
|
||||
uco = gConverterInfo[i].mEncoder;
|
||||
} else {
|
||||
uco = gConverterInfo[i].mDecoder;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return uco;
|
||||
}
|
||||
|
||||
void OS2Uni::FreeUconvObjects()
|
||||
{
|
||||
for (int i = 0; i < eCONVERTER_COUNT; i++) {
|
||||
NS_IF_RELEASE(gConverterInfo[i].mEncoder);
|
||||
NS_IF_RELEASE(gConverterInfo[i].mDecoder);
|
||||
}
|
||||
NS_IF_RELEASE(gCharsetManager);
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
WideCharToMultiByte
|
||||
**********************************************************/
|
||||
NS_GFX_(nsresult)
|
||||
WideCharToMultiByte(int aCodePage, const PRUnichar* aSrc,
|
||||
PRInt32 aSrcLength, nsAutoCharBuffer& aResult,
|
||||
PRInt32& aResultLength)
|
||||
{
|
||||
nsresult rv;
|
||||
nsISupports* sup = OS2Uni::GetUconvObject(aCodePage, eConv_Encoder);
|
||||
nsCOMPtr<nsIUnicodeEncoder> uco = do_QueryInterface(sup);
|
||||
|
||||
if (NS_FAILED(uco->GetMaxLength(aSrc, aSrcLength, &aResultLength))) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (!aResult.EnsureElemCapacity(aResultLength + 1))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
char* str = aResult.get();
|
||||
|
||||
rv = uco->Convert(aSrc, &aSrcLength, str, &aResultLength);
|
||||
aResult.get()[aResultLength] = '\0';
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
MultiByteToWideChar
|
||||
**********************************************************/
|
||||
NS_GFX_(nsresult)
|
||||
MultiByteToWideChar(int aCodePage, const char* aSrc,
|
||||
PRInt32 aSrcLength, nsAutoChar16Buffer& aResult,
|
||||
PRInt32& aResultLength)
|
||||
{
|
||||
nsresult rv;
|
||||
nsISupports* sup = OS2Uni::GetUconvObject(aCodePage, eConv_Decoder);
|
||||
nsCOMPtr<nsIUnicodeDecoder> uco = do_QueryInterface(sup);
|
||||
|
||||
if (NS_FAILED(uco->GetMaxLength(aSrc, aSrcLength, &aResultLength))) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (!aResult.EnsureElemCapacity(aResultLength + 1))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
PRUnichar* str = aResult.get();
|
||||
|
||||
rv = uco->Convert(aSrc, &aSrcLength, str, &aResultLength);
|
||||
aResult.get()[aResultLength] = '\0';
|
||||
return rv;
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/* ***** 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 an API for accessing OS/2 Unicode support.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 _nsos2uni_h
|
||||
#define _nsos2uni_h
|
||||
|
||||
#define INCL_WIN
|
||||
#include <os2.h>
|
||||
#include <uconv.h>
|
||||
#include "nsAutoBuffer.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "gfxCore.h"
|
||||
|
||||
|
||||
enum ConverterRequest {
|
||||
eConv_Encoder,
|
||||
eConv_Decoder
|
||||
};
|
||||
|
||||
class NS_GFX OS2Uni {
|
||||
public:
|
||||
static nsISupports* GetUconvObject(int CodePage, ConverterRequest aReq);
|
||||
static void FreeUconvObjects();
|
||||
private:
|
||||
static nsICharsetConverterManager* gCharsetManager;
|
||||
};
|
||||
|
||||
|
||||
#define CHAR_BUFFER_SIZE 1024
|
||||
typedef nsAutoBuffer<char, CHAR_BUFFER_SIZE> nsAutoCharBuffer;
|
||||
typedef nsAutoBuffer<PRUnichar, CHAR_BUFFER_SIZE> nsAutoChar16Buffer;
|
||||
|
||||
NS_GFX_(nsresult) WideCharToMultiByte(int aCodePage, const PRUnichar* aSrc,
|
||||
PRInt32 aSrcLength, nsAutoCharBuffer& aResult,
|
||||
PRInt32& aResultLength);
|
||||
NS_GFX_(nsresult) MultiByteToWideChar(int aCodePage, const char* aSrc,
|
||||
PRInt32 aSrcLength, nsAutoChar16Buffer& aResult,
|
||||
PRInt32& aResultLength);
|
||||
|
||||
#endif
|
@ -1,177 +0,0 @@
|
||||
/* ***** 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 an API for using the OS/2 Palette Manager.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 "nsPaletteOS2.h"
|
||||
#include "nsGfxDefs.h"
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
HPAL nsPaletteOS2::hGlobalPalette = NULLHANDLE;
|
||||
BOOL nsPaletteOS2::fPaletteInitialized = FALSE;
|
||||
ULONG nsPaletteOS2::aulTable[256];
|
||||
|
||||
#define NUM_SYS_COLORS 24
|
||||
|
||||
typedef struct _MYRGB {
|
||||
BYTE red;
|
||||
BYTE green;
|
||||
BYTE blue;
|
||||
} MYRGB;
|
||||
|
||||
MYRGB sysColors[NUM_SYS_COLORS] =
|
||||
{
|
||||
0x00, 0x00, 0x00, // CLR_BLACK
|
||||
0x00, 0x00, 0x80, // CLR_DARKBLUE
|
||||
0x00, 0x80, 0x00, // CLR_DARKGREEN
|
||||
0x00, 0x80, 0x80, // CLR_DARKCYAN
|
||||
0x80, 0x00, 0x00, // CLR_DARKRED
|
||||
0x80, 0x00, 0x80, // CLR_DARKPINK
|
||||
0x80, 0x80, 0x00, // CLR_BROWN
|
||||
0x80, 0x80, 0x80, // CLR_DARKGRAY
|
||||
0xCC, 0xCC, 0xCC, // CLR_PALEGRAY
|
||||
0x00, 0x00, 0xFF, // CLR_BLUE
|
||||
0x00, 0xFF, 0x00, // CLR_GREEN
|
||||
0x00, 0xFF, 0xFF, // CLR_CYAN
|
||||
0xFF, 0x00, 0x00, // CLR_RED
|
||||
0xFF, 0x00, 0xFF, // CLR_PINK
|
||||
0xFF, 0xFF, 0x00, // CLR_YELLOW
|
||||
0xFE, 0xFE, 0xFE, // CLR_OFFWHITE - can only use white at index 255
|
||||
|
||||
0xC0, 0xC0, 0xC0, // Gray (Windows)
|
||||
0xFF, 0xFB, 0xF0, // Pale Yellow (Windows)
|
||||
0xC0, 0xDC, 0xC0, // Pale Green (Windows)
|
||||
0xA4, 0xC8, 0xF0, // Light Blue (Windows)
|
||||
0xA4, 0xA0, 0xA4, // Medium Gray (Windows)
|
||||
|
||||
0xFF, 0xFF, 0xE4, // Tooltip color - see nsLookAndFeel.cpp
|
||||
|
||||
0x71, 0x71, 0x71, // Interpolated color for entryfields
|
||||
0xEF, 0xEF, 0xEF // Interpolated color for entryfields
|
||||
|
||||
};
|
||||
|
||||
void nsPaletteOS2::InitializeGlobalPalette()
|
||||
{
|
||||
fPaletteInitialized = TRUE;
|
||||
LONG lCaps;
|
||||
HPS hps = ::WinGetScreenPS(HWND_DESKTOP);
|
||||
HDC hdc = ::GpiQueryDevice (hps);
|
||||
::DevQueryCaps(hdc, CAPS_ADDITIONAL_GRAPHICS, 1, &lCaps);
|
||||
::WinReleasePS(hps);
|
||||
|
||||
if (lCaps & CAPS_PALETTE_MANAGER) {
|
||||
/* Create the color table */
|
||||
int i,j,k,l, ulCurTableEntry = 0;
|
||||
|
||||
/* First add the system colors */
|
||||
for (i = 0; i < NUM_SYS_COLORS; i++) {
|
||||
aulTable[ulCurTableEntry] = MK_RGB(sysColors[i].red, sysColors[i].green, sysColors[i].blue);
|
||||
ulCurTableEntry++;
|
||||
}
|
||||
|
||||
/* Then put the color cube into the table, excluding */
|
||||
/* any entry that is also in the system color table */
|
||||
for (i=0x00;i <= 0xff;i+=0x33) {
|
||||
for (j=0x00;j <= 0xff;j+=0x33) {
|
||||
for (k=0x00;k <= 0xff ;k+=0x33) {
|
||||
for (l=0;l<ulCurTableEntry;l++) {
|
||||
if (aulTable[l] == MK_RGB(i, j, k))
|
||||
break;
|
||||
}
|
||||
if (l == ulCurTableEntry) {
|
||||
aulTable[ulCurTableEntry] = MK_RGB(i, j, k);
|
||||
ulCurTableEntry++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Back current table entry up one so we overwrite the white that was written */
|
||||
/* by the color cube */
|
||||
ulCurTableEntry--;
|
||||
|
||||
/* Then fudge the rest of the table to have entries that are neither white */
|
||||
/* nor black - we'll use an offwhite */
|
||||
while (ulCurTableEntry < 255) {
|
||||
aulTable[ulCurTableEntry] = MK_RGB(254, 254, 254);
|
||||
ulCurTableEntry++;
|
||||
}
|
||||
|
||||
/* Finally, make the last entry white */
|
||||
aulTable[ulCurTableEntry] = MK_RGB(255, 255, 255);
|
||||
|
||||
#ifdef DEBUG_mikek
|
||||
for (i=0;i<256 ;i++ )
|
||||
printf("Entry[%d] in 256 color table is %x\n", i, aulTable[i]);
|
||||
#endif
|
||||
|
||||
/* Create the palette */
|
||||
hGlobalPalette = ::GpiCreatePalette ((HAB)0, 0,
|
||||
LCOLF_CONSECRGB, 256, aulTable);
|
||||
}
|
||||
}
|
||||
|
||||
void nsPaletteOS2::FreeGlobalPalette()
|
||||
{
|
||||
if (hGlobalPalette) {
|
||||
GpiDeletePalette(hGlobalPalette);
|
||||
hGlobalPalette = NULLHANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
void nsPaletteOS2::SelectGlobalPalette(HPS hps, HWND hwnd)
|
||||
{
|
||||
if (!fPaletteInitialized)
|
||||
InitializeGlobalPalette();
|
||||
if (hGlobalPalette) {
|
||||
GpiSelectPalette(hps, hGlobalPalette);
|
||||
if (hwnd != NULLHANDLE) {
|
||||
ULONG cclr;
|
||||
WinRealizePalette(hwnd, hps, &cclr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LONG nsPaletteOS2::QueryColorIndex(LONG lColor)
|
||||
{
|
||||
for (int i=0;i<256;i++) {
|
||||
if (lColor == aulTable[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/* ***** 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 an API for using the OS/2 Palette Manager.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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 _nspaletteos2_h
|
||||
#define _nspaletteos2_h
|
||||
|
||||
#define INCL_WIN
|
||||
#define INCL_GPI
|
||||
#include <os2.h>
|
||||
#include "gfxCore.h"
|
||||
|
||||
class NS_GFX nsPaletteOS2 {
|
||||
public:
|
||||
static void FreeGlobalPalette();
|
||||
static void InitializeGlobalPalette();
|
||||
static void SelectGlobalPalette(HPS hps, HWND hwnd = NULLHANDLE);
|
||||
static LONG QueryColorIndex(LONG lColor);
|
||||
private:
|
||||
static HPAL hGlobalPalette;
|
||||
static BOOL fPaletteInitialized;
|
||||
static ULONG aulTable[256];
|
||||
};
|
||||
|
||||
#endif
|
@ -1,467 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Peter Weilbacher <mozilla@weilbacher.org>
|
||||
*
|
||||
* 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 "nsPrintOS2.h"
|
||||
|
||||
#include "nsOS2Uni.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// OS/2 Printing - was in libprint.cpp
|
||||
//---------------------------------------------------------------------------
|
||||
static HMODULE hmodRes;
|
||||
|
||||
#define SHIFT_PTR(ptr,offset) ( *((LONG*)&ptr) += offset )
|
||||
|
||||
|
||||
class NS_GFX PRTQUEUE
|
||||
{
|
||||
public:
|
||||
PRTQUEUE (const PRQINFO3* pPQI3) { InitWithPQI3 (pPQI3); }
|
||||
PRTQUEUE (const PRTQUEUE& PQInfo);
|
||||
~PRTQUEUE (void) { free (mpPQI3); }
|
||||
|
||||
PRQINFO3& PQI3 () const { return *mpPQI3; }
|
||||
const char* DriverName () const { return mDriverName; }
|
||||
const char* DeviceName () const { return mDeviceName; }
|
||||
const char* PrinterName() const { return mPrinterName; }
|
||||
const char* QueueName () const { return mpPQI3->pszComment; }
|
||||
|
||||
private:
|
||||
PRTQUEUE& operator = (const PRTQUEUE& z); // prevent copying
|
||||
void InitWithPQI3 (const PRQINFO3* pInfo);
|
||||
|
||||
PRQINFO3* mpPQI3;
|
||||
unsigned mPQI3BufSize;
|
||||
char mDriverName [DRIV_NAME_SIZE + 1]; // Driver name
|
||||
char mDeviceName [DRIV_DEVICENAME_SIZE + 1]; // Device name
|
||||
char mPrinterName [PRINTERNAME_SIZE + 1]; // Printer name
|
||||
};
|
||||
|
||||
|
||||
PRTQUEUE::PRTQUEUE (const PRTQUEUE& PQInfo)
|
||||
{
|
||||
mPQI3BufSize = PQInfo.mPQI3BufSize;
|
||||
mpPQI3 = (PRQINFO3*)malloc (mPQI3BufSize);
|
||||
memcpy (mpPQI3, PQInfo.mpPQI3, mPQI3BufSize); // Copy entire buffer
|
||||
|
||||
long Diff = (long)mpPQI3 - (long)PQInfo.mpPQI3; // Calculate the difference between addresses
|
||||
SHIFT_PTR (mpPQI3->pszName, Diff); // Modify internal pointers accordingly
|
||||
SHIFT_PTR (mpPQI3->pszSepFile, Diff);
|
||||
SHIFT_PTR (mpPQI3->pszPrProc, Diff);
|
||||
SHIFT_PTR (mpPQI3->pszParms, Diff);
|
||||
SHIFT_PTR (mpPQI3->pszComment, Diff);
|
||||
SHIFT_PTR (mpPQI3->pszPrinters, Diff);
|
||||
SHIFT_PTR (mpPQI3->pszDriverName, Diff);
|
||||
SHIFT_PTR (mpPQI3->pDriverData, Diff);
|
||||
|
||||
strcpy (mDriverName, PQInfo.mDriverName);
|
||||
strcpy (mDeviceName, PQInfo.mDeviceName);
|
||||
strcpy (mPrinterName, PQInfo.mPrinterName);
|
||||
}
|
||||
|
||||
void PRTQUEUE::InitWithPQI3(const PRQINFO3* pInfo)
|
||||
{
|
||||
// Make local copy of PPRQINFO3 object
|
||||
ULONG SizeNeeded;
|
||||
::SplQueryQueue (NULL, pInfo->pszName, 3, NULL, 0, &SizeNeeded);
|
||||
mpPQI3 = (PRQINFO3*)malloc (SizeNeeded);
|
||||
::SplQueryQueue (NULL, pInfo->pszName, 3, mpPQI3, SizeNeeded, &SizeNeeded);
|
||||
|
||||
mPQI3BufSize = SizeNeeded;
|
||||
|
||||
PCHAR sep = strchr (pInfo->pszDriverName, '.');
|
||||
|
||||
if (sep)
|
||||
{
|
||||
*sep = '\0';
|
||||
strcpy (mDriverName, pInfo->pszDriverName);
|
||||
strcpy (mDeviceName, sep + 1);
|
||||
*sep = '.';
|
||||
} else
|
||||
{
|
||||
strcpy (mDriverName, pInfo->pszDriverName);
|
||||
mDeviceName [0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
sep = strchr (pInfo->pszPrinters, ',');
|
||||
|
||||
if (sep)
|
||||
{
|
||||
*sep = '\0';
|
||||
strcpy (mPrinterName, pInfo->pszPrinters);
|
||||
*sep = '.';
|
||||
} else
|
||||
{
|
||||
strcpy (mPrinterName, pInfo->pszPrinters);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
|
||||
PRINTDLG::PRINTDLG()
|
||||
{
|
||||
mQueueCount = 0;
|
||||
|
||||
ULONG TotalQueues = 0;
|
||||
ULONG MemNeeded = 0;
|
||||
SPLERR rc;
|
||||
|
||||
rc = ::SplEnumQueue(NULL, 3, NULL, 0, &mQueueCount, &TotalQueues, &MemNeeded, NULL);
|
||||
PRQINFO3* pPQI3Buf = (PRQINFO3*) malloc (MemNeeded);
|
||||
rc = ::SplEnumQueue(NULL, 3, pPQI3Buf, MemNeeded, &mQueueCount, &TotalQueues, &MemNeeded, NULL);
|
||||
|
||||
if (mQueueCount > MAX_PRINT_QUEUES)
|
||||
mQueueCount = MAX_PRINT_QUEUES;
|
||||
|
||||
ULONG defaultQueue = 0;
|
||||
for (ULONG cnt = 0; cnt < mQueueCount; cnt++) {
|
||||
if (pPQI3Buf[cnt].fsType & PRQ3_TYPE_APPDEFAULT)
|
||||
defaultQueue = cnt;
|
||||
mPQBuf[cnt] = new PRTQUEUE(&pPQI3Buf[cnt]);
|
||||
}
|
||||
|
||||
// move the entry for the default printer to index 0 (if necessary)
|
||||
if (defaultQueue > 0) {
|
||||
PRTQUEUE* temp = mPQBuf[0];
|
||||
mPQBuf[0] = mPQBuf[defaultQueue];
|
||||
mPQBuf[defaultQueue] = temp;
|
||||
}
|
||||
|
||||
free(pPQI3Buf);
|
||||
}
|
||||
|
||||
PRINTDLG::~PRINTDLG()
|
||||
{
|
||||
for (ULONG index = 0; index < mQueueCount; index++)
|
||||
delete mPQBuf[index];
|
||||
}
|
||||
|
||||
void PRINTDLG::RefreshPrintQueue()
|
||||
{
|
||||
ULONG newQueueCount = 0;
|
||||
ULONG TotalQueues = 0;
|
||||
ULONG MemNeeded = 0;
|
||||
SPLERR rc;
|
||||
|
||||
rc = ::SplEnumQueue(NULL, 3, NULL, 0, &newQueueCount, &TotalQueues, &MemNeeded, NULL);
|
||||
PRQINFO3* pPQI3Buf = (PRQINFO3*)malloc(MemNeeded);
|
||||
rc = ::SplEnumQueue(NULL, 3, pPQI3Buf, MemNeeded, &newQueueCount, &TotalQueues, &MemNeeded, NULL);
|
||||
|
||||
if (newQueueCount > MAX_PRINT_QUEUES)
|
||||
newQueueCount = MAX_PRINT_QUEUES;
|
||||
|
||||
PRTQUEUE* tmpBuf[MAX_PRINT_QUEUES];
|
||||
|
||||
ULONG defaultQueue = 0;
|
||||
for (ULONG cnt = 0; cnt < newQueueCount; cnt++) {
|
||||
if (pPQI3Buf[cnt].fsType & PRQ3_TYPE_APPDEFAULT)
|
||||
defaultQueue = cnt;
|
||||
|
||||
BOOL found = FALSE;
|
||||
for (ULONG index = 0; index < mQueueCount && !found; index++) {
|
||||
//Compare printer from requeried list with what's already in Mozilla's printer list(mPQBuf)
|
||||
//If printer is already there, use current properties; otherwise create a new printer in list
|
||||
if (mPQBuf[index] != 0) {
|
||||
if ((strcmp(pPQI3Buf[cnt].pszPrinters, mPQBuf[index]->PrinterName()) == 0) &&
|
||||
(strcmp(pPQI3Buf[cnt].pszDriverName, mPQBuf[index]->PQI3().pszDriverName) == 0)) {
|
||||
found = TRUE;
|
||||
tmpBuf[cnt] = mPQBuf[index];
|
||||
mPQBuf[index] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
tmpBuf[cnt] = new PRTQUEUE(&pPQI3Buf[cnt]);
|
||||
}
|
||||
|
||||
for (ULONG index = 0; index < newQueueCount; index++) {
|
||||
if (mPQBuf[index] != 0)
|
||||
delete(mPQBuf[index]);
|
||||
mPQBuf[index] = tmpBuf[index];
|
||||
}
|
||||
|
||||
if (mQueueCount > newQueueCount)
|
||||
for (ULONG index = newQueueCount; index < mQueueCount; index++)
|
||||
if (mPQBuf[index] != 0)
|
||||
delete(mPQBuf[index]);
|
||||
|
||||
mQueueCount = newQueueCount;
|
||||
|
||||
// move the entry for the default printer to index 0 (if necessary)
|
||||
if (defaultQueue > 0) {
|
||||
PRTQUEUE* temp = mPQBuf[0];
|
||||
mPQBuf[0] = mPQBuf[defaultQueue];
|
||||
mPQBuf[defaultQueue] = temp;
|
||||
}
|
||||
|
||||
free(pPQI3Buf);
|
||||
}
|
||||
|
||||
ULONG PRINTDLG::GetNumPrinters()
|
||||
{
|
||||
return mQueueCount;
|
||||
}
|
||||
|
||||
void PRINTDLG::GetPrinter(ULONG printerNdx, char** printerName)
|
||||
{
|
||||
if (printerNdx >= mQueueCount)
|
||||
return;
|
||||
|
||||
nsCAutoString pName(mPQBuf[printerNdx]->QueueName());
|
||||
|
||||
pName.ReplaceChar('\r', ' ');
|
||||
pName.StripChars("\n");
|
||||
*printerName = ToNewCString(pName);
|
||||
}
|
||||
|
||||
PRTQUEUE* PRINTDLG::SetPrinterQueue(ULONG printerNdx)
|
||||
{
|
||||
PRTQUEUE *pPQ = NULL;
|
||||
|
||||
if (printerNdx >= mQueueCount)
|
||||
return NULL;
|
||||
|
||||
pPQ = mPQBuf[printerNdx];
|
||||
|
||||
return new PRTQUEUE(*pPQ);
|
||||
}
|
||||
|
||||
LONG PRINTDLG::GetPrintDriverSize(ULONG printerNdx)
|
||||
{
|
||||
return mPQBuf[printerNdx]->PQI3().pDriverData->cb;
|
||||
}
|
||||
|
||||
PDRIVDATA PRINTDLG::GetPrintDriver(ULONG printerNdx)
|
||||
{
|
||||
if (printerNdx >= mQueueCount)
|
||||
return NULL;
|
||||
|
||||
return mPQBuf[printerNdx]->PQI3().pDriverData;
|
||||
}
|
||||
|
||||
HDC PRINTDLG::GetDCHandle(ULONG printerNdx)
|
||||
{
|
||||
HDC hdc = 0;
|
||||
DEVOPENSTRUC dop;
|
||||
|
||||
dop.pszLogAddress = 0;
|
||||
dop.pszDriverName = (char *)mPQBuf[printerNdx]->DriverName();
|
||||
dop.pdriv = mPQBuf[printerNdx]->PQI3().pDriverData;
|
||||
dop.pszDataType = 0;
|
||||
dop.pszComment = 0;
|
||||
dop.pszQueueProcName = 0;
|
||||
dop.pszQueueProcParams = 0;
|
||||
dop.pszSpoolerParams = 0;
|
||||
dop.pszNetworkParams = 0;
|
||||
|
||||
hdc = ::DevOpenDC(0, OD_INFO, "*", 9, (PDEVOPENDATA) &dop, NULLHANDLE);
|
||||
return hdc;
|
||||
}
|
||||
|
||||
char* PRINTDLG::GetDriverType(ULONG printerNdx)
|
||||
{
|
||||
return (char *)mPQBuf[printerNdx]->DriverName ();
|
||||
}
|
||||
|
||||
BOOL PRINTDLG::ShowProperties(ULONG printerNdx)
|
||||
{
|
||||
BOOL rc = FALSE;
|
||||
LONG devrc = FALSE;
|
||||
PDRIVDATA pOldDrivData;
|
||||
PDRIVDATA pNewDrivData = NULL;
|
||||
LONG buflen;
|
||||
|
||||
/* check size of buffer required for job properties */
|
||||
buflen = DevPostDeviceModes( 0 /*hab*/,
|
||||
NULL,
|
||||
mPQBuf[printerNdx]->DriverName (),
|
||||
mPQBuf[printerNdx]->DeviceName (),
|
||||
mPQBuf[printerNdx]->PrinterName (),
|
||||
DPDM_POSTJOBPROP);
|
||||
|
||||
/* return error to caller */
|
||||
if (buflen <= 0)
|
||||
return(buflen);
|
||||
|
||||
/* allocate some memory for larger job properties and */
|
||||
/* return error to caller */
|
||||
|
||||
if (buflen != mPQBuf[printerNdx]->PQI3().pDriverData->cb)
|
||||
{
|
||||
if (DosAllocMem((PPVOID)&pNewDrivData,buflen,fALLOC))
|
||||
return(FALSE); // DPDM_ERROR
|
||||
|
||||
/* copy over old data so driver can use old job */
|
||||
/* properties as base for job properties dialog */
|
||||
pOldDrivData = mPQBuf[printerNdx]->PQI3().pDriverData;
|
||||
mPQBuf[printerNdx]->PQI3().pDriverData = pNewDrivData;
|
||||
memcpy( (PSZ)pNewDrivData, (PSZ)pOldDrivData, pOldDrivData->cb );
|
||||
}
|
||||
|
||||
/* display job properties dialog and get updated */
|
||||
/* job properties from driver */
|
||||
|
||||
devrc = DevPostDeviceModes( 0 /*hab*/,
|
||||
mPQBuf[printerNdx]->PQI3().pDriverData,
|
||||
mPQBuf[printerNdx]->DriverName (),
|
||||
mPQBuf[printerNdx]->DeviceName (),
|
||||
mPQBuf[printerNdx]->PrinterName (),
|
||||
DPDM_POSTJOBPROP);
|
||||
rc = (devrc != DPDM_ERROR);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Job management */
|
||||
/****************************************************************************/
|
||||
|
||||
NS_GFX_(HDC) PrnOpenDC( PRTQUEUE *pInfo, PSZ pszApplicationName, int copies, int destination, char *file )
|
||||
{
|
||||
HDC hdc = 0;
|
||||
PSZ pszLogAddress;
|
||||
PSZ pszDataType;
|
||||
LONG dcType;
|
||||
DEVOPENSTRUC dop;
|
||||
|
||||
if (!pInfo || !pszApplicationName)
|
||||
return hdc;
|
||||
|
||||
if ( destination ) {
|
||||
pszLogAddress = pInfo->PQI3 ().pszName;
|
||||
pszDataType = "PM_Q_STD";
|
||||
if ( destination == 2 )
|
||||
dcType = OD_METAFILE;
|
||||
else
|
||||
dcType = OD_QUEUED;
|
||||
} else {
|
||||
if (file && *file)
|
||||
pszLogAddress = (PSZ) file;
|
||||
else
|
||||
pszLogAddress = "FILE";
|
||||
pszDataType = "PM_Q_RAW";
|
||||
dcType = OD_DIRECT;
|
||||
}
|
||||
|
||||
dop.pszLogAddress = pszLogAddress;
|
||||
dop.pszDriverName = (char*)pInfo->DriverName ();
|
||||
dop.pdriv = pInfo->PQI3 ().pDriverData;
|
||||
dop.pszDataType = pszDataType;
|
||||
dop.pszComment = pszApplicationName;
|
||||
dop.pszQueueProcName = pInfo->PQI3 ().pszPrProc;
|
||||
dop.pszQueueProcParams = 0;
|
||||
dop.pszSpoolerParams = 0;
|
||||
dop.pszNetworkParams = 0;
|
||||
|
||||
hdc = ::DevOpenDC( 0, dcType, "*", 9, (PDEVOPENDATA) &dop, NULLHANDLE);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (hdc == 0)
|
||||
{
|
||||
ULONG ErrorCode = ERRORIDERROR (::WinGetLastError (0));
|
||||
printf ("!ERROR! - Can't open DC for printer %04lX\a\n", ErrorCode);
|
||||
}
|
||||
#endif
|
||||
|
||||
return hdc;
|
||||
}
|
||||
|
||||
/* find the selected form */
|
||||
NS_GFX_(BOOL) PrnQueryHardcopyCaps( HDC hdc, PHCINFO pHCInfo)
|
||||
{
|
||||
BOOL rc = FALSE;
|
||||
|
||||
if( hdc && pHCInfo)
|
||||
{
|
||||
PHCINFO pBuffer;
|
||||
long lAvail, i;
|
||||
|
||||
/* query how many forms are available */
|
||||
lAvail = ::DevQueryHardcopyCaps( hdc, 0, 0, NULL);
|
||||
|
||||
pBuffer = (PHCINFO) malloc( lAvail * sizeof(HCINFO));
|
||||
|
||||
::DevQueryHardcopyCaps( hdc, 0, lAvail, pBuffer);
|
||||
|
||||
for( i = 0; i < lAvail; i++)
|
||||
if( pBuffer[ i].flAttributes & HCAPS_CURRENT)
|
||||
{
|
||||
memcpy( pHCInfo, pBuffer + i, sizeof(HCINFO));
|
||||
rc = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
free( pBuffer);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* Library-level data and functions -Printing */
|
||||
/****************************************************************************/
|
||||
|
||||
NS_GFX_(BOOL) PrnInitialize( HMODULE hmodResources)
|
||||
{
|
||||
hmodRes = hmodResources;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NS_GFX_(BOOL) PrnTerminate()
|
||||
{
|
||||
/* nop for now, may do something eventually */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NS_GFX_(BOOL) PrnClosePrinter( PRTQUEUE *pPrintQueue)
|
||||
{
|
||||
BOOL rc = FALSE;
|
||||
|
||||
if (pPrintQueue)
|
||||
{
|
||||
delete pPrintQueue;
|
||||
rc = TRUE;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -1,100 +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):
|
||||
* John Fairhurst <john_fairhurst@iname.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 nsPrintOS2_h___
|
||||
#define nsPrintOS2_h___
|
||||
|
||||
#define INCL_PM
|
||||
#define INCL_DOS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_SPLDOSPRINT
|
||||
#define INCL_DEV
|
||||
#define INCL_DEVDJP
|
||||
#define INCL_GRE_DEVICE
|
||||
#include <os2.h>
|
||||
#include <pmddim.h>
|
||||
#include "gfxCore.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// OS/2 Printing - was in libprint
|
||||
//---------------------------------------------------------------------------
|
||||
// Library init and term; job properties per queue are cached during run.
|
||||
NS_GFX_(BOOL) PrnInitialize(HMODULE hmodResources);
|
||||
NS_GFX_(BOOL) PrnTerminate(void);
|
||||
|
||||
// opaque type to describe a print queue (printer)
|
||||
class NS_GFX PRTQUEUE;
|
||||
|
||||
#define MAX_PRINT_QUEUES (128)
|
||||
|
||||
class NS_GFX PRINTDLG
|
||||
{
|
||||
public:
|
||||
PRINTDLG();
|
||||
~PRINTDLG();
|
||||
void RefreshPrintQueue();
|
||||
ULONG GetNumPrinters();
|
||||
void GetPrinter(ULONG printerNdx, char** printerName);
|
||||
PRTQUEUE* SetPrinterQueue(ULONG printerNdx);
|
||||
LONG GetPrintDriverSize(ULONG printerNdx);
|
||||
PDRIVDATA GetPrintDriver(ULONG printerNdx);
|
||||
HDC GetDCHandle(ULONG printerNdx);
|
||||
char* GetDriverType(ULONG printerNdx);
|
||||
BOOL ShowProperties(ULONG printerNdx);
|
||||
|
||||
private:
|
||||
ULONG mQueueCount;
|
||||
PRTQUEUE* mPQBuf[MAX_PRINT_QUEUES];
|
||||
};
|
||||
|
||||
|
||||
// Release app. resources associated with a printer
|
||||
NS_GFX_(BOOL) PrnClosePrinter( PRTQUEUE *pPrintQueue);
|
||||
|
||||
// Get a DC for the selected printer. Must supply the application name.
|
||||
NS_GFX_(HDC) PrnOpenDC( PRTQUEUE *pPrintQueue, PSZ pszApplicationName, int copies, int destination, char *file);
|
||||
|
||||
// Get the hardcopy caps for the selected form
|
||||
NS_GFX_(BOOL) PrnQueryHardcopyCaps( HDC hdc, PHCINFO pHCInfo);
|
||||
|
||||
// Abort the current job started with PrnStartJob().
|
||||
NS_GFX_(BOOL) PrnAbortJob( HDC hdc);
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,270 +0,0 @@
|
||||
/* ***** 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
|
||||
* Dainis Jonitis, <Dainis_Jonitis@swh-t.lv>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* 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 "nsRegionOS2.h"
|
||||
#include "nsGfxDefs.h"
|
||||
|
||||
nsRegionOS2::nsRegionOS2()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsRegionOS2, nsIRegion)
|
||||
|
||||
PRUint32 nsRegionOS2::NumOfRects (HPS aPS, HRGN aRegion) const
|
||||
{
|
||||
RGNRECT rgnRect;
|
||||
rgnRect.ircStart = 1;
|
||||
rgnRect.crc = 0xFFFFFFFF;
|
||||
rgnRect.crcReturned = 0;
|
||||
rgnRect.ulDirection = RECTDIR_LFRT_TOPBOT;
|
||||
|
||||
GFX (::GpiQueryRegionRects (aPS, aRegion, NULL, &rgnRect, NULL), FALSE);
|
||||
|
||||
return rgnRect.crcReturned;
|
||||
}
|
||||
|
||||
HRGN nsRegionOS2::GetHRGN (PRUint32 DestHeight, HPS DestPS)
|
||||
{
|
||||
PRUint32 NumRects = mRegion.GetNumRects ();
|
||||
|
||||
if (NumRects > 0)
|
||||
{
|
||||
PRECTL pRects = new RECTL [NumRects];
|
||||
|
||||
nsRegionRectIterator ri (mRegion);
|
||||
const nsRect* pSrc;
|
||||
PRECTL pDest = pRects;
|
||||
|
||||
while ((pSrc = ri.Next()))
|
||||
{
|
||||
pDest->xLeft = pSrc->x;
|
||||
pDest->xRight = pSrc->XMost ();
|
||||
pDest->yTop = DestHeight - pSrc->y;
|
||||
pDest->yBottom = pDest->yTop - pSrc->height;
|
||||
pDest++;
|
||||
}
|
||||
|
||||
HRGN rgn = GFX (::GpiCreateRegion (DestPS, NumRects, pRects), RGN_ERROR);
|
||||
delete [] pRects;
|
||||
|
||||
return rgn;
|
||||
} else
|
||||
{
|
||||
return GFX (::GpiCreateRegion (DestPS, 0, NULL), RGN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// For copying from an existing region who has height & possibly diff. hdc
|
||||
nsresult nsRegionOS2::InitWithHRGN (HRGN SrcRegion, PRUint32 SrcHeight, HPS SrcPS)
|
||||
{
|
||||
PRUint32 NumRects = NumOfRects (SrcPS, SrcRegion);
|
||||
mRegion.SetEmpty ();
|
||||
|
||||
if (NumRects > 0)
|
||||
{
|
||||
RGNRECT RgnControl = { 1, NumRects, 0, RECTDIR_LFRT_TOPBOT };
|
||||
PRECTL pRects = new RECTL [NumRects];
|
||||
|
||||
GFX (::GpiQueryRegionRects (SrcPS, SrcRegion, NULL, &RgnControl, pRects), FALSE);
|
||||
|
||||
for (PRUint32 cnt = 0 ; cnt < NumRects ; cnt++)
|
||||
mRegion.Or (mRegion, nsRect ( pRects [cnt].xLeft, SrcHeight - pRects [cnt].yTop,
|
||||
pRects [cnt].xRight - pRects [cnt].xLeft, pRects [cnt].yTop - pRects [cnt].yBottom));
|
||||
|
||||
delete [] pRects;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsRegionOS2::Init (void)
|
||||
{
|
||||
mRegion.SetEmpty ();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsRegionOS2::SetTo (const nsIRegion &aRegion)
|
||||
{
|
||||
const nsRegionOS2* pRegion = static_cast<const nsRegionOS2*>(&aRegion);
|
||||
mRegion = pRegion->mRegion;
|
||||
}
|
||||
|
||||
void nsRegionOS2::SetTo (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
mRegion = nsRect (aX, aY, aWidth, aHeight);
|
||||
}
|
||||
|
||||
void nsRegionOS2::Intersect (const nsIRegion &aRegion)
|
||||
{
|
||||
const nsRegionOS2* pRegion = static_cast<const nsRegionOS2*>(&aRegion);
|
||||
mRegion.And (mRegion, pRegion->mRegion);
|
||||
}
|
||||
|
||||
void nsRegionOS2::Intersect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
mRegion.And (mRegion, nsRect (aX, aY, aWidth, aHeight));
|
||||
}
|
||||
|
||||
void nsRegionOS2::Union (const nsIRegion &aRegion)
|
||||
{
|
||||
const nsRegionOS2* pRegion = static_cast<const nsRegionOS2*>(&aRegion);
|
||||
mRegion.Or (mRegion, pRegion->mRegion);
|
||||
}
|
||||
|
||||
void nsRegionOS2::Union (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
mRegion.Or (mRegion, nsRect (aX, aY, aWidth, aHeight));
|
||||
}
|
||||
|
||||
void nsRegionOS2::Subtract (const nsIRegion &aRegion)
|
||||
{
|
||||
const nsRegionOS2* pRegion = static_cast<const nsRegionOS2*>(&aRegion);
|
||||
mRegion.Sub (mRegion, pRegion->mRegion);
|
||||
}
|
||||
|
||||
void nsRegionOS2::Subtract (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
mRegion.Sub (mRegion, nsRect (aX, aY, aWidth, aHeight));
|
||||
}
|
||||
|
||||
PRBool nsRegionOS2::IsEmpty (void)
|
||||
{
|
||||
return mRegion.IsEmpty ();
|
||||
}
|
||||
|
||||
PRBool nsRegionOS2::IsEqual (const nsIRegion &aRegion)
|
||||
{
|
||||
const nsRegionOS2* pRegion = static_cast<const nsRegionOS2*>(&aRegion);
|
||||
return mRegion.IsEqual (pRegion->mRegion);
|
||||
}
|
||||
|
||||
void nsRegionOS2::GetBoundingBox (PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
|
||||
{
|
||||
const nsRect& BoundRect = mRegion.GetBounds();
|
||||
*aX = BoundRect.x;
|
||||
*aY = BoundRect.y;
|
||||
*aWidth = BoundRect.width;
|
||||
*aHeight = BoundRect.height;
|
||||
}
|
||||
|
||||
void nsRegionOS2::Offset (PRInt32 aXOffset, PRInt32 aYOffset)
|
||||
{
|
||||
mRegion.MoveBy (aXOffset, aYOffset);
|
||||
}
|
||||
|
||||
PRBool nsRegionOS2::ContainsRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
nsRegion TmpRegion;
|
||||
TmpRegion.And (mRegion, nsRect (aX, aY, aWidth, aHeight));
|
||||
return (!TmpRegion.IsEmpty ());
|
||||
}
|
||||
|
||||
nsresult nsRegionOS2::GetRects (nsRegionRectSet **aRects)
|
||||
{
|
||||
if (!aRects)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRegionRectSet* pRegionSet = *aRects;
|
||||
PRUint32 NumRects = mRegion.GetNumRects ();
|
||||
|
||||
if (!pRegionSet) // Not yet allocated
|
||||
{
|
||||
PRUint8* pBuf = new PRUint8 [sizeof (nsRegionRectSet) + NumRects * sizeof (nsRegionRect)];
|
||||
pRegionSet = reinterpret_cast<nsRegionRectSet*>(pBuf);
|
||||
pRegionSet->mRectsLen = NumRects + 1;
|
||||
} else // Already allocated in previous call
|
||||
{
|
||||
if (NumRects > pRegionSet->mRectsLen) // passed array is not big enough - reallocate it.
|
||||
{
|
||||
delete [] reinterpret_cast<PRUint8*>(pRegionSet);
|
||||
PRUint8* pBuf = new PRUint8 [sizeof (nsRegionRectSet) + NumRects * sizeof (nsRegionRect)];
|
||||
pRegionSet = reinterpret_cast<nsRegionRectSet*>(pBuf);
|
||||
pRegionSet->mRectsLen = NumRects + 1;
|
||||
}
|
||||
}
|
||||
pRegionSet->mNumRects = NumRects;
|
||||
*aRects = pRegionSet;
|
||||
|
||||
|
||||
nsRegionRectIterator ri (mRegion);
|
||||
nsRegionRect* pDest = &pRegionSet->mRects [0];
|
||||
const nsRect* pSrc;
|
||||
|
||||
while ((pSrc = ri.Next ()) != nsnull)
|
||||
{
|
||||
pDest->x = pSrc->x;
|
||||
pDest->y = pSrc->y;
|
||||
pDest->width = pSrc->width;
|
||||
pDest->height = pSrc->height;
|
||||
|
||||
++pDest;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsRegionOS2::FreeRects (nsRegionRectSet *aRects)
|
||||
{
|
||||
if (!aRects)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
delete [] reinterpret_cast<PRUint8*>(aRects);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsRegionOS2::GetNativeRegion (void *&aRegion) const
|
||||
{
|
||||
aRegion = RGN_ERROR;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsRegionOS2::GetRegionComplexity (nsRegionComplexity &aComplexity) const
|
||||
{
|
||||
switch (mRegion.GetNumRects ())
|
||||
{
|
||||
case 0: aComplexity = eRegionComplexity_empty; break;
|
||||
case 1: aComplexity = eRegionComplexity_rect; break;
|
||||
default: aComplexity = eRegionComplexity_complex; break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsRegionOS2::GetNumRects (PRUint32 *aRects) const
|
||||
{
|
||||
*aRects = mRegion.GetNumRects ();
|
||||
return NS_OK;
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/* ***** 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
|
||||
* Dainis Jonitis, <Dainis_Jonitis@swh-t.lv>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* 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 _nsRegionOS2_h
|
||||
#define _nsRegionOS2_h
|
||||
|
||||
#include "nsiRegion.h"
|
||||
#include "nsRegion.h"
|
||||
#define INCL_GPI
|
||||
#include <os2.h>
|
||||
|
||||
class nsRegionOS2 : public nsIRegion
|
||||
{
|
||||
PRUint32 NumOfRects (HPS aPS, HRGN aRegion) const;
|
||||
|
||||
public:
|
||||
nsRegionOS2 ();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
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);
|
||||
// Don't use this on OS/2 - Use GetHRGN () instead
|
||||
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const;
|
||||
|
||||
// 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 InitWithHRGN (HRGN copy, PRUint32 ulHeight, HPS hps);
|
||||
private:
|
||||
nsRegion mRegion;
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,266 +0,0 @@
|
||||
/* ***** 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 OS/2 libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* John Fairhurst, <john_fairhurst@iname.com>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Henry Sobotka <sobotka@axess.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.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 *****
|
||||
*
|
||||
* 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 "nsUnitConversion.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsRect.h"
|
||||
#include "nscoord.h"
|
||||
#include "nsImageOS2.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIRenderingContextOS2.h"
|
||||
#include "nsDrawingSurfaceOS2.h"
|
||||
#include "nsRenderingContextImpl.h"
|
||||
|
||||
class GraphicsState;
|
||||
class nsDrawingSurfaceOS2;
|
||||
class nsFontOS2;
|
||||
|
||||
class nsRenderingContextOS2 : public nsRenderingContextImpl,
|
||||
nsIRenderingContextOS2
|
||||
{
|
||||
public:
|
||||
nsRenderingContextOS2();
|
||||
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIDrawingSurface* aSurface);
|
||||
|
||||
NS_IMETHOD Reset(void);
|
||||
|
||||
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(void);
|
||||
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsIDrawingSurface* aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsIDrawingSurface* *aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
||||
NS_IMETHOD PushState(void);
|
||||
NS_IMETHOD PopState(void);
|
||||
|
||||
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aClipState);
|
||||
|
||||
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
|
||||
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipState);
|
||||
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
|
||||
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
|
||||
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
|
||||
|
||||
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
|
||||
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
|
||||
|
||||
NS_IMETHOD SetColor(nscolor aColor);
|
||||
NS_IMETHOD GetColor(nscolor &aColor) const;
|
||||
|
||||
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup);
|
||||
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
|
||||
|
||||
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
|
||||
|
||||
NS_IMETHOD Translate(nscoord aX, nscoord aY);
|
||||
NS_IMETHOD Scale(float aSx, float aSy);
|
||||
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
|
||||
|
||||
NS_IMETHOD CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurfFlags, nsIDrawingSurface* &aSurface);
|
||||
NS_IMETHOD DestroyDrawingSurface(nsIDrawingSurface* aDS);
|
||||
|
||||
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 InvertRect(const nsRect& aRect);
|
||||
NS_IMETHOD InvertRect(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 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);
|
||||
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth,
|
||||
PRInt32 *aFontID);
|
||||
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);
|
||||
|
||||
NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
|
||||
nsTextDimensions& aDimensions);
|
||||
NS_IMETHOD GetTextDimensions(const PRUnichar *aString, PRUint32 aLength,
|
||||
nsTextDimensions& aDimensions, PRInt32 *aFontID);
|
||||
NS_IMETHOD GetTextDimensions(const char* aString,
|
||||
PRInt32 aLength,
|
||||
PRInt32 aAvailWidth,
|
||||
PRInt32* aBreaks,
|
||||
PRInt32 aNumBreaks,
|
||||
nsTextDimensions& aDimensions,
|
||||
PRInt32& aNumCharsFit,
|
||||
nsTextDimensions& aLastWordDimensions,
|
||||
PRInt32* aFontID = nsnull);
|
||||
NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
|
||||
PRInt32 aLength,
|
||||
PRInt32 aAvailWidth,
|
||||
PRInt32* aBreaks,
|
||||
PRInt32 aNumBreaks,
|
||||
nsTextDimensions& aDimensions,
|
||||
PRInt32& aNumCharsFit,
|
||||
nsTextDimensions& aLastWordDimensions,
|
||||
PRInt32* aFontID = nsnull);
|
||||
|
||||
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
const nscoord* aSpacing);
|
||||
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID,
|
||||
const nscoord* aSpacing);
|
||||
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID,
|
||||
const nscoord* aSpacing);
|
||||
|
||||
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface* aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
void* GetNativeGraphicData(GraphicDataType aType);
|
||||
|
||||
|
||||
NS_IMETHOD CreateDrawingSurface(HPS aPS, nsIDrawingSurface* &aSurface, nsIWidget *aWidget);
|
||||
|
||||
#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
|
||||
|
||||
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 );
|
||||
|
||||
nsresult CommonInit (void);
|
||||
nsresult SetupPS (void);
|
||||
LONG GetGPIColor (void);
|
||||
void PushClipState(void);
|
||||
|
||||
|
||||
// Colour/font setting; call before drawing things.
|
||||
void SetupLineColorAndStyle (void);
|
||||
void SetupFillColor (void);
|
||||
void SetupFontAndColor (void);
|
||||
|
||||
// Primitive draw-ers
|
||||
void PMDrawRect( nsRect &rect, BOOL fill);
|
||||
void PMDrawPoly( const nsPoint aPoints[], PRInt32 aNumPoints, PRBool bFilled, PRBool bDoTransform = PR_TRUE);
|
||||
void PMDrawArc( nsRect &rect, PRBool bFilled, PRBool bFull, float start=0, float end=0);
|
||||
|
||||
protected:
|
||||
|
||||
~nsRenderingContextOS2();
|
||||
|
||||
nsIDeviceContext *mContext; // device context
|
||||
nsDrawingSurfaceOS2 *mSurface; // draw things here
|
||||
nsDrawingSurfaceOS2 *mMainSurface; // if offscreen selected, this is original one that was set on init time
|
||||
nscolor mColor; // current colour
|
||||
nsLineStyle mLineStyle; // current line style
|
||||
nsTransform2D mTMatrix; // current xform matrix
|
||||
float mP2T; // cache pix-2-app factor from DC
|
||||
GraphicsState *mStates;
|
||||
nsVoidArray *mStateCache;
|
||||
nsIFontMetrics *mFontMetrics; // current font
|
||||
nscolor mCurrFillColor; // currently selected fill color
|
||||
PRBool mPreservedInitialClipRegion;
|
||||
PRBool mPaletteMode; // GPI colors are indexes into selected palette
|
||||
HPS mPS; // GPI presentation space of current drawing surface
|
||||
nsIWidget *mDCOwner; // Parent widget
|
||||
nsFontOS2 *mCurrFontOS2;
|
||||
|
||||
PRBool mRightToLeftText;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -1,126 +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) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Henry Sobotka <sobotka@axess.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 "nsScreenManagerOS2.h"
|
||||
#include "nsScreenOS2.h"
|
||||
|
||||
|
||||
nsScreenManagerOS2 :: nsScreenManagerOS2 ( )
|
||||
{
|
||||
// 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.
|
||||
}
|
||||
|
||||
|
||||
nsScreenManagerOS2 :: ~nsScreenManagerOS2()
|
||||
{
|
||||
// nothing to see here.
|
||||
}
|
||||
|
||||
|
||||
// addref, release, QI
|
||||
NS_IMPL_ISUPPORTS1(nsScreenManagerOS2, 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*
|
||||
nsScreenManagerOS2 :: CreateNewScreenObject ( )
|
||||
{
|
||||
nsIScreen* retval = nsnull;
|
||||
if ( !mCachedMainScreen )
|
||||
mCachedMainScreen = new nsScreenOS2 ( );
|
||||
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
|
||||
nsScreenManagerOS2 :: 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
|
||||
nsScreenManagerOS2 :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
|
||||
{
|
||||
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
|
||||
return NS_OK;
|
||||
|
||||
} // GetPrimaryScreen
|
||||
|
||||
|
||||
//
|
||||
// GetNumberOfScreens
|
||||
//
|
||||
// Returns how many physical screens are available.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerOS2 :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
|
||||
{
|
||||
*aNumberOfScreens = 1;
|
||||
return NS_OK;
|
||||
|
||||
} // GetNumberOfScreens
|
||||
|
@ -1,65 +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) 2000
|
||||
* 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 nsScreenManagerOS2_h___
|
||||
#define nsScreenManagerOS2_h___
|
||||
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIScreen.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
class nsScreenManagerOS2 : public nsIScreenManager
|
||||
{
|
||||
public:
|
||||
nsScreenManagerOS2 ( );
|
||||
virtual ~nsScreenManagerOS2();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREENMANAGER
|
||||
|
||||
private:
|
||||
|
||||
nsIScreen* CreateNewScreenObject ( ) ;
|
||||
|
||||
// cache the primary screen object to avoid memory allocation every time
|
||||
nsCOMPtr<nsIScreen> mCachedMainScreen;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsScreenManagerOS2_h___
|
@ -1,155 +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) 2000
|
||||
* 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 "nsScreenOS2.h"
|
||||
#include "nsGfxDefs.h"
|
||||
|
||||
nsScreenOS2 :: nsScreenOS2 ( )
|
||||
{
|
||||
// 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.
|
||||
}
|
||||
|
||||
|
||||
nsScreenOS2 :: ~nsScreenOS2()
|
||||
{
|
||||
// nothing to see here.
|
||||
}
|
||||
|
||||
|
||||
// addref, release, QI
|
||||
NS_IMPL_ISUPPORTS1(nsScreenOS2, nsIScreen)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||
{
|
||||
LONG alArray[2];
|
||||
|
||||
HPS hps = ::WinGetScreenPS( HWND_DESKTOP);
|
||||
HDC hdc = GFX (::GpiQueryDevice (hps), HDC_ERROR);
|
||||
::DevQueryCaps(hdc, CAPS_WIDTH, 2, alArray);
|
||||
::WinReleasePS(hps);
|
||||
|
||||
*outTop = 0;
|
||||
*outLeft = 0;
|
||||
*outWidth = alArray[0];
|
||||
*outHeight = alArray[1];
|
||||
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetRect
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||
{
|
||||
static APIRET rc = 0;
|
||||
static BOOL (APIENTRY * pfnQueryDesktopWorkArea)(HWND hwndDesktop, PWRECT pwrcWorkArea) = NULL;
|
||||
|
||||
GetRect(outLeft, outTop, outWidth, outHeight);
|
||||
|
||||
// This height is different based on whether or not
|
||||
// "Show on top of maximed windows" is checked
|
||||
LONG lWorkAreaHeight = *outHeight;
|
||||
|
||||
if ( !rc && !pfnQueryDesktopWorkArea )
|
||||
{
|
||||
HMODULE hmod = 0;
|
||||
rc = DosLoadModule( NULL, 0, "PMMERGE", &hmod );
|
||||
if ( !rc )
|
||||
{
|
||||
rc = DosQueryProcAddr( hmod, 5469, NULL, (PFN*) &pfnQueryDesktopWorkArea ); // WinQueryDesktopWorkArea
|
||||
DosFreeModule(hmod);
|
||||
}
|
||||
}
|
||||
if ( pfnQueryDesktopWorkArea && !rc )
|
||||
{
|
||||
RECTL rectl;
|
||||
pfnQueryDesktopWorkArea( HWND_DESKTOP, &rectl );
|
||||
lWorkAreaHeight = rectl.yTop - rectl.yBottom;
|
||||
}
|
||||
|
||||
HWND hwndWarpCenter = WinWindowFromID( HWND_DESKTOP, 0x555 );
|
||||
if (hwndWarpCenter) {
|
||||
/* If "Show on top of maximized windows is checked" */
|
||||
if (lWorkAreaHeight != *outHeight) {
|
||||
SWP swp;
|
||||
WinQueryWindowPos( hwndWarpCenter, &swp );
|
||||
if (swp.y != 0) {
|
||||
/* WarpCenter is at the top */
|
||||
*outTop += swp.cy;
|
||||
}
|
||||
*outHeight -= swp.cy;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailRect
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||
{
|
||||
LONG lCap;
|
||||
|
||||
HPS hps = ::WinGetScreenPS( HWND_DESKTOP);
|
||||
HDC hdc = GFX (::GpiQueryDevice (hps), HDC_ERROR);
|
||||
|
||||
GFX (::DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &lCap), FALSE);
|
||||
|
||||
*aPixelDepth = (PRInt32)lCap;
|
||||
|
||||
|
||||
::WinReleasePS(hps);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetPixelDepth
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
return GetPixelDepth ( aColorDepth );
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
|
@ -1,58 +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) 2000
|
||||
* 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 nsScreenOS2_h___
|
||||
#define nsScreenOS2_h___
|
||||
|
||||
#include "nsIScreen.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
class nsScreenOS2 : public nsIScreen
|
||||
{
|
||||
public:
|
||||
nsScreenOS2 ( );
|
||||
virtual ~nsScreenOS2();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREEN
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // nsScreenOS2_h___
|
@ -100,7 +100,6 @@ MAKEFILES_gfx="
|
||||
gfx/src/psshared/Makefile
|
||||
gfx/src/photon/Makefile
|
||||
gfx/src/mac/Makefile
|
||||
gfx/src/os2/Makefile
|
||||
gfx/src/windows/Makefile
|
||||
gfx/src/thebes/Makefile
|
||||
gfx/tests/Makefile
|
||||
|
@ -68,16 +68,14 @@ REQUIRES = gfx \
|
||||
imglib2 \
|
||||
unicharutil \
|
||||
layout \
|
||||
cairo \
|
||||
thebes \
|
||||
$(NULL)
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
EXPORTS = wdgtos2rc.h
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_CAIRO_GFX
|
||||
REQUIRES += cairo thebes
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
nsAppShell.cpp \
|
||||
nsBidiKeyboard.cpp \
|
||||
@ -85,6 +83,9 @@ CPPSRCS = \
|
||||
nsFilePicker.cpp \
|
||||
nsFrameWindow.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsOS2Uni.cpp \
|
||||
nsPaletteOS2.cpp \
|
||||
nsPrintOS2.cpp \
|
||||
nsSound.cpp \
|
||||
nsToolkit.cpp \
|
||||
nsWidgetFactory.cpp \
|
||||
@ -106,13 +107,10 @@ EXTRA_DSO_LDOPTS = \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
-lthebes \
|
||||
$(LCMS_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_CAIRO_GFX
|
||||
EXTRA_DSO_LDOPTS += -lthebes
|
||||
endif
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
HAS_EXTRAEXPORTS = 1
|
||||
endif
|
||||
|
@ -51,75 +51,13 @@
|
||||
|
||||
#include <uconv.h> // XXX hack XXX
|
||||
|
||||
#define COLOR_CUBE_SIZE 216
|
||||
|
||||
void PMERROR(const char *str);
|
||||
|
||||
// Wrapper code for all OS/2 system calls to check the return code for error condition in debug build.
|
||||
// Could be used like this:
|
||||
//
|
||||
// HDC hdc = GFX (::GpiQueryDevice (ps), HDC_ERROR);
|
||||
// GFX (::GpiAssociate (mPrintPS, 0), FALSE);
|
||||
// return GFX (::GpiDestroyPS (mPrintPS), FALSE);
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void DEBUG_LogErr(long ReturnCode, const char* ErrorExpression,
|
||||
const char* FileName, const char* FunctionName,
|
||||
long LineNum);
|
||||
|
||||
inline long CheckSuccess(long ReturnCode, long SuccessCode,
|
||||
const char* ErrorExpression, const char* FileName,
|
||||
const char* FunctionName, long LineNum)
|
||||
{
|
||||
if (ReturnCode != SuccessCode) {
|
||||
DEBUG_LogErr(ReturnCode, ErrorExpression, FileName, FunctionName, LineNum);
|
||||
}
|
||||
return ReturnCode;
|
||||
}
|
||||
|
||||
#define CHK_SUCCESS(ReturnCode, SuccessCode) \
|
||||
CheckSuccess(ReturnCode, SuccessCode, #ReturnCode, __FILE__, \
|
||||
__FUNCTION__, __LINE__)
|
||||
|
||||
inline long CheckFailure(long ReturnCode, long ErrorCode,
|
||||
const char* ErrorExpression, const char* FileName,
|
||||
const char* FunctionName, long LineNum)
|
||||
{
|
||||
if (ReturnCode == ErrorCode) {
|
||||
DEBUG_LogErr(ReturnCode, ErrorExpression, FileName, FunctionName, LineNum);
|
||||
}
|
||||
return ReturnCode;
|
||||
}
|
||||
|
||||
/* #define CHK_FAIL(ReturnCode, ErrorCode) \ */
|
||||
#define GFX(ReturnCode, ErrorCode) \
|
||||
CheckFailure(ReturnCode, ErrorCode, #ReturnCode, __FILE__, \
|
||||
__FUNCTION__, __LINE__)
|
||||
|
||||
#else // Retail build
|
||||
#define CHK_SUCCESS(ReturnCode, SuccessCode) ReturnCode
|
||||
/* #define CHK_FAIL(ReturnCode, ErrorCode) ReturnCode */
|
||||
#define GFX(ReturnCode, ErrorCode) ReturnCode
|
||||
#endif
|
||||
|
||||
class nsString;
|
||||
class nsIDeviceContext;
|
||||
|
||||
|
||||
BOOL GetTextExtentPoint32(HPS aPS, const char* aString, int aLength, PSIZEL aSizeL);
|
||||
BOOL ExtTextOut(HPS aPS, int X, int Y, UINT fuOptions, const RECTL* lprc,
|
||||
const char* aString, unsigned int aLength, const int* pDx);
|
||||
|
||||
BOOL IsDBCS();
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define MK_RGB(r,g,b) ((r) * 65536) + ((g) * 256) + (b)
|
||||
|
||||
#ifdef DEBUG
|
||||
extern PRLogModuleInfo *gGFXOS2LogModule;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -48,12 +48,6 @@
|
||||
#include "nsFont.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
#include "gfxOS2Surface.h"
|
||||
#include "gfxContext.h"
|
||||
#else
|
||||
#include "nsIRenderingContextOS2.h"
|
||||
#endif
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsRect.h"
|
||||
@ -238,10 +232,7 @@ nsWindow::nsWindow() : nsBaseWidget()
|
||||
mCssCursorHPtr = 0;
|
||||
|
||||
mIsTopWidgetWindow = PR_FALSE;
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
mThebesSurface = nsnull;
|
||||
#endif
|
||||
|
||||
if (!gGlobalsInitialized) {
|
||||
gGlobalsInitialized = PR_TRUE;
|
||||
@ -1093,7 +1084,6 @@ NS_METHOD nsWindow::Create(nsNativeWidget aParent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create a Thebes surface using the current window handle
|
||||
@ -1106,7 +1096,6 @@ gfxASurface* nsWindow::GetThebesSurface()
|
||||
}
|
||||
return mThebesSurface;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
@ -1137,10 +1126,8 @@ NS_METHOD nsWindow::Destroy()
|
||||
CaptureRollupEvents(nsnull, PR_FALSE, PR_TRUE);
|
||||
}
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
// Destroy thebes surface now, XXX do we need this at all??
|
||||
mThebesSurface = nsnull;
|
||||
#endif
|
||||
|
||||
if (mWnd) {
|
||||
HWND hwndBeingDestroyed = mFrameWnd ? mFrameWnd : mWnd;
|
||||
@ -3179,7 +3166,7 @@ PRBool nsWindow::OnPaint()
|
||||
(PRInt32)mWnd);
|
||||
#endif // NS_DEBUG
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX // Thebes code version, adapted from windows/nsWindow.cpp
|
||||
// Thebes code version, adapted from windows/nsWindow.cpp
|
||||
// XXX as a preliminary solution for repaint problems of cairo-os2
|
||||
// builds, repaint the whole window for each paint event
|
||||
// see Bug 371505
|
||||
@ -3214,30 +3201,6 @@ PRBool nsWindow::OnPaint()
|
||||
thebesContext->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
thebesContext->Paint();
|
||||
}
|
||||
#else // code without Thebes follows
|
||||
static NS_DEFINE_CID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
|
||||
|
||||
if (NS_SUCCEEDED(CallCreateInstance(kRenderingContextCID, &event.renderingContext))) {
|
||||
nsIRenderingContextOS2 *winrc;
|
||||
|
||||
if (NS_OK == event.renderingContext->QueryInterface(NS_GET_IID(nsIRenderingContextOS2), (void **)&winrc)) {
|
||||
nsIDrawingSurface* surf;
|
||||
|
||||
//i know all of this seems a little backwards. i'll fix it, i swear. MMP
|
||||
|
||||
if (NS_OK == winrc->CreateDrawingSurface(hPS, surf, event.widget)) {
|
||||
event.renderingContext->Init(mContext, surf);
|
||||
rc = DispatchWindowEvent(&event, eventStatus);
|
||||
event.renderingContext->DestroyDrawingSurface(surf);
|
||||
}
|
||||
|
||||
NS_RELEASE(winrc);
|
||||
} // if event.renderingContext->QI
|
||||
} // instance of rendering context
|
||||
|
||||
NS_RELEASE(event.renderingContext);
|
||||
NS_RELEASE(event.widget);
|
||||
#endif // this was the code without Thebes
|
||||
} // if (mEventCallback)
|
||||
} // if (!WinIsRectEmpty(0, &rcl))
|
||||
|
||||
|
@ -58,10 +58,8 @@
|
||||
#include "nsBaseWidget.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsSwitchToUIThread.h"
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
#include <gfxOS2Surface.h>
|
||||
#endif
|
||||
#include "gfxOS2Surface.h"
|
||||
#include "gfxContext.h"
|
||||
|
||||
class imgIContainer;
|
||||
|
||||
@ -127,9 +125,7 @@ class nsWindow : public nsBaseWidget,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
gfxASurface* GetThebesSurface();
|
||||
#endif
|
||||
NS_IMETHOD Destroy(); // call before releasing
|
||||
|
||||
// Hierarchy: only interested in widget children (it seems)
|
||||
@ -292,9 +288,7 @@ protected:
|
||||
nsFont *mFont;
|
||||
nsIMenuBar *mMenuBar;
|
||||
PRInt32 mWindowState;
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
nsRefPtr<gfxOS2Surface> mThebesSurface;
|
||||
#endif
|
||||
|
||||
// Implementation ------------------------------
|
||||
void DoCreate( HWND hwndP, nsWindow *wndP, const nsRect &rect,
|
||||
|
Loading…
Reference in New Issue
Block a user