mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
r=mkaply, a=brendan Port of nsDeviceContextOS2 to be more like Windows and removal of nsPaletteOS2
This commit is contained in:
parent
3b8c9f1a14
commit
0cb64066c3
@ -45,7 +45,6 @@ CPPSRCS = \
|
|||||||
nsScreenOS2.cpp \
|
nsScreenOS2.cpp \
|
||||||
nsScreenManagerOS2.cpp \
|
nsScreenManagerOS2.cpp \
|
||||||
nsGfxFactoryOS2.cpp \
|
nsGfxFactoryOS2.cpp \
|
||||||
nsPaletteOS2.cpp \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
RES_FILE = $(srcdir)/libprint.res
|
RES_FILE = $(srcdir)/libprint.res
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/*
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
* 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"
|
* The contents of this file are subject to the Mozilla Public
|
||||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
* License Version 1.1 (the "License"); you may not use this file
|
||||||
* License for the specific language governing rights and limitations
|
* except in compliance with the License. You may obtain a copy of
|
||||||
* under the License.
|
* 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 Original Code is the Mozilla OS/2 libraries.
|
||||||
*
|
*
|
||||||
@ -15,73 +16,62 @@
|
|||||||
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
|
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
|
||||||
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
|
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s): Henry Sobotka <sobotka@axess.com> 2OOO/O2 update
|
* Contributor(s):
|
||||||
*
|
* Henry Sobotka <sobotka@axess.com> 2OOO/O2 update
|
||||||
* This Original Code has been modified by IBM Corporation.
|
* IBM Corp.
|
||||||
* 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
|
|
||||||
* ---- ----------- ---------------------------
|
|
||||||
* 5/31/2000 IBM Corp. Add method isPrintDC() to class nsDeviceContextOS2 to use in file
|
|
||||||
* nsRenderingContextOS2.cpp
|
|
||||||
* 06/07/2000 IBM Corp. Corrected querying of screen and client sizes
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ToDo:
|
|
||||||
#include "nsGfxDefs.h"
|
|
||||||
#include "libprint.h"
|
|
||||||
|
|
||||||
#include "nsDeviceContextSpecOS2.h"
|
|
||||||
#include "nsDeviceContextOS2.h"
|
#include "nsDeviceContextOS2.h"
|
||||||
#include "nsDrawingSurfaceOS2.h"
|
#include "nsRenderingContextOS2.h"
|
||||||
#include "nsPaletteOS2.h"
|
#include "nsDeviceContextSpecOS2.h"
|
||||||
#include "nsHashtable.h"
|
|
||||||
#include "nsString.h"
|
|
||||||
#include "nsFont.h"
|
|
||||||
#include "il_util.h"
|
#include "il_util.h"
|
||||||
|
#include "nsIPref.h"
|
||||||
|
#include "nsIServiceManager.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsIScreenManager.h"
|
||||||
|
#include "nsIScreen.h"
|
||||||
|
|
||||||
// nsDeviceContextOS2 - The graphics state associated with a window.
|
#include "nsHashTable.h" // For CreateFontAliasTable()
|
||||||
// Keep the colour palette for all rendering contexts here; they share
|
|
||||||
// it and the widget can do palette-y things.
|
|
||||||
//
|
|
||||||
// Remember that this thing can be fairly long-lived, linked to a window.
|
|
||||||
//
|
|
||||||
// It's a bit schizophrenic - really there should be a nsIPrintDC <: nsIDC ...
|
|
||||||
|
|
||||||
// Init/Term -----------------------------------------------------------------
|
#include "nsGfxDefs.h"
|
||||||
|
|
||||||
|
// Size of the color cube
|
||||||
|
#define COLOR_CUBE_SIZE 216
|
||||||
|
|
||||||
#define NOT_SETUP 0x33
|
#define NOT_SETUP 0x33
|
||||||
static PRBool gIsWarp4 = NOT_SETUP;
|
static PRBool gIsWarp4 = NOT_SETUP;
|
||||||
|
|
||||||
nsDeviceContextOS2::nsDeviceContextOS2() : DeviceContextImpl()
|
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||||
{
|
|
||||||
// Default for now
|
|
||||||
mSurface = nsnull;
|
|
||||||
mDepth = 0;
|
|
||||||
mPaletteInfo.isPaletteDevice = PR_FALSE;
|
|
||||||
mPaletteInfo.sizePalette = 0;
|
|
||||||
mPaletteInfo.numReserved = 0;
|
|
||||||
mPaletteInfo.palette = nsnull;
|
|
||||||
mPalette = nsnull;
|
|
||||||
mPixelsToTwips = 0;
|
|
||||||
mTwipsToPixels = 0;
|
|
||||||
mPixelScale = 1.0f;
|
|
||||||
mWidth = -1;
|
|
||||||
mHeight = -1;
|
|
||||||
mPrintDC = nsnull;
|
|
||||||
mSpec = nsnull;
|
|
||||||
mCachedClientRect = PR_FALSE;
|
|
||||||
mCachedFullRect = PR_FALSE;
|
|
||||||
mPrintState = nsPrintState_ePreBeginDoc;
|
|
||||||
|
|
||||||
// Init module if necessary (XXX find a better way of doing this!)
|
PRBool nsDeviceContextOS2::gRound = PR_FALSE;
|
||||||
|
PRUint32 nsDeviceContextOS2::sNumberOfScreens = 0;
|
||||||
|
|
||||||
|
static char* nav4rounding = "font.size.nav4rounding";
|
||||||
|
|
||||||
|
nsDeviceContextOS2 :: nsDeviceContextOS2()
|
||||||
|
: DeviceContextImpl()
|
||||||
|
{
|
||||||
|
mSurface = nsnull;
|
||||||
|
mPaletteInfo.isPaletteDevice = PR_FALSE;
|
||||||
|
mPaletteInfo.sizePalette = 0;
|
||||||
|
mPaletteInfo.numReserved = 0;
|
||||||
|
mPaletteInfo.palette = nsnull;
|
||||||
|
mDC = nsnull;
|
||||||
|
mPixelScale = 1.0f;
|
||||||
|
mWidth = -1;
|
||||||
|
mHeight = -1;
|
||||||
|
mSpec = nsnull;
|
||||||
|
mCachedClientRect = PR_FALSE;
|
||||||
|
mCachedFullRect = PR_FALSE;
|
||||||
|
#ifdef XP_OS2
|
||||||
|
mPrintState = nsPrintState_ePreBeginDoc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef XP_OS2 // OS2TODO - GET RID OF THIS!
|
||||||
|
// Init module if necessary
|
||||||
if( !gModuleData.lDisplayDepth)
|
if( !gModuleData.lDisplayDepth)
|
||||||
gModuleData.Init();
|
gModuleData.Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
// The first time in we initialize gIsWarp4 flag
|
// The first time in we initialize gIsWarp4 flag
|
||||||
if (NOT_SETUP == gIsWarp4) {
|
if (NOT_SETUP == gIsWarp4) {
|
||||||
@ -90,144 +80,163 @@ nsDeviceContextOS2::nsDeviceContextOS2() : DeviceContextImpl()
|
|||||||
ulValues, sizeof(ulValues));
|
ulValues, sizeof(ulValues));
|
||||||
gIsWarp4 = (ulValues[0] >= 20) && (ulValues[1] >= 40);
|
gIsWarp4 = (ulValues[0] >= 20) && (ulValues[1] >= 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef XP_OS2
|
||||||
|
nsresult res = NS_ERROR_FAILURE;
|
||||||
|
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res);
|
||||||
|
if (NS_SUCCEEDED(res)) {
|
||||||
|
static PRBool roundingInitialized = PR_FALSE;
|
||||||
|
if (!roundingInitialized) {
|
||||||
|
roundingInitialized = PR_TRUE;
|
||||||
|
PrefChanged(nav4rounding, this);
|
||||||
|
}
|
||||||
|
prefs->RegisterCallback(nav4rounding, PrefChanged, this);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsDeviceContextOS2::~nsDeviceContextOS2()
|
nsDeviceContextOS2::~nsDeviceContextOS2()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE( mSurface);
|
if(mDC)
|
||||||
NS_IF_RELEASE( mPalette);
|
{
|
||||||
|
GpiAssociate(mPS, 0);
|
||||||
|
GpiDestroyPS(mPS);
|
||||||
|
PrnCloseDC(mDC);
|
||||||
|
}
|
||||||
|
|
||||||
if( mPrintDC)
|
NS_IF_RELEASE(mSpec);
|
||||||
{
|
|
||||||
GpiAssociate( mPS, 0);
|
|
||||||
GpiDestroyPS( mPS);
|
|
||||||
PrnCloseDC( mPrintDC);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IF_RELEASE(mSpec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::Init( nsNativeWidget aWidget)
|
nsresult nsDeviceContextOS2::Init( nsNativeWidget aWidget)
|
||||||
{
|
{
|
||||||
HWND hwnd = aWidget ? (HWND)aWidget : HWND_DESKTOP;
|
nsresult retval = DeviceContextImpl::Init(aWidget);
|
||||||
HDC hdc = WinOpenWindowDC( hwnd);
|
|
||||||
|
|
||||||
CommonInit( hdc);
|
HWND hwnd = (HWND)aWidget;
|
||||||
|
HDC hdc = WinOpenWindowDC(hwnd);
|
||||||
|
|
||||||
// Get size - don't know if this is needed for non-print DCs
|
CommonInit(hdc);
|
||||||
long lCaps[2];
|
|
||||||
DevQueryCaps( hdc, CAPS_WIDTH, 2, lCaps);
|
|
||||||
mWidth = lCaps[0]; // these are in device units...
|
|
||||||
mHeight = lCaps[1];
|
|
||||||
|
|
||||||
// Don't need to close HDCs obtained from WinOpenWindowDC
|
#ifdef XP_OS2 /* OS2TODO - Why are we doing this? These were set in CommonInit */
|
||||||
|
// Get size - don't know if this is needed for non-print DCs
|
||||||
|
long lCaps[2];
|
||||||
|
DevQueryCaps( hdc, CAPS_WIDTH, 2, lCaps);
|
||||||
|
mWidth = lCaps[0]; // these are in device units...
|
||||||
|
mHeight = lCaps[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
return DeviceContextImpl::Init( aWidget);
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This version of Init() is called when creating a print DC
|
// This version of Init() is called when creating a print DC
|
||||||
nsresult nsDeviceContextOS2::Init( nsNativeDeviceContext aContext,
|
nsresult nsDeviceContextOS2::Init( nsNativeDeviceContext aContext,
|
||||||
nsIDeviceContext *aOrigContext)
|
nsIDeviceContext *aOrigContext)
|
||||||
{
|
{
|
||||||
// These calcs are from the windows version & I'm not 100%
|
float origscale, newscale;
|
||||||
// sure what's going on...
|
float t2d, a2d;
|
||||||
|
|
||||||
float origscale, newscale;
|
mDC = (HDC)aContext;
|
||||||
float t2d, a2d;
|
|
||||||
|
|
||||||
mPrintDC = (HDC)aContext; // we are print dc...
|
#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 };
|
||||||
|
mPS = GpiCreatePS( 0/*hab*/, mDC, &sizel,
|
||||||
|
PU_PELS | GPIT_MICRO | GPIA_ASSOC);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Create a print PS now. This is necessary 'cos we need it from
|
CommonInit( mDC);
|
||||||
// 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 };
|
|
||||||
mPS = GpiCreatePS( 0/*hab*/, mPrintDC, &sizel,
|
|
||||||
PU_PELS | GPIT_MICRO | GPIA_ASSOC);
|
|
||||||
|
|
||||||
CommonInit( mPrintDC);
|
GetTwipsToDevUnits( newscale);
|
||||||
|
aOrigContext->GetTwipsToDevUnits( origscale);
|
||||||
|
|
||||||
GetTwipsToDevUnits( newscale);
|
mPixelScale = newscale / origscale;
|
||||||
aOrigContext->GetTwipsToDevUnits( origscale);
|
|
||||||
|
|
||||||
mPixelScale = newscale / origscale;
|
aOrigContext->GetTwipsToDevUnits( t2d);
|
||||||
|
aOrigContext->GetAppUnitsToDevUnits( a2d);
|
||||||
|
|
||||||
aOrigContext->GetTwipsToDevUnits( t2d);
|
mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels;
|
||||||
aOrigContext->GetAppUnitsToDevUnits( a2d);
|
mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;
|
||||||
|
|
||||||
mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels;
|
#ifdef XP_OS2
|
||||||
mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;
|
HCINFO hcinfo;
|
||||||
|
PrnQueryHardcopyCaps( mDC, &hcinfo);
|
||||||
|
mWidth = hcinfo.xPels;
|
||||||
|
mHeight = hcinfo.yPels;
|
||||||
|
// XXX hsb says there are margin problems, must be from here...
|
||||||
|
printf( "Got surface of size %d x %d pixels\n", mWidth, mHeight);
|
||||||
|
printf( "mPixelScale = %f\n", mPixelScale);
|
||||||
|
|
||||||
HCINFO hcinfo;
|
// We need to begin a document now, because the client is entitled at
|
||||||
PrnQueryHardcopyCaps( mPrintDC, &hcinfo);
|
// this point to do stuff like create fonts, which required the PS to
|
||||||
mWidth = hcinfo.xPels;
|
// be associated with a DC which has been DEVESC_STARTDOC'd.
|
||||||
mHeight = hcinfo.yPels;
|
BeginDocument();
|
||||||
// XXX hsb says there are margin problems, must be from here...
|
#endif
|
||||||
printf( "Got surface of size %d x %d pixels\n", mWidth, mHeight);
|
|
||||||
printf( "mPixelScale = %f\n", mPixelScale);
|
|
||||||
|
|
||||||
// We need to begin a document now, because the client is entitled at
|
return NS_OK;
|
||||||
// this point to do stuff like create fonts, which required the PS to
|
|
||||||
// be associated with a DC which has been DEVESC_STARTDOC'd.
|
|
||||||
BeginDocument();
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXXX Reduce to one call to DevQueryCaps???
|
void nsDeviceContextOS2 :: CommonInit(HDC aDC)
|
||||||
void nsDeviceContextOS2::CommonInit( HDC aDC)
|
|
||||||
{
|
{
|
||||||
// Record palette-potential of device even if it is >8bpp
|
LONG alArray[CAPS_DEVICE_POLYSET_POINTS];
|
||||||
long lCap = 0;
|
|
||||||
DevQueryCaps( aDC, CAPS_ADDITIONAL_GRAPHICS, 1, &lCap);
|
|
||||||
mPaletteInfo.isPaletteDevice = !!(lCap & CAPS_PALETTE_MANAGER);
|
|
||||||
|
|
||||||
// Work out the pels-to-twips conversion
|
DevQueryCaps(aDC, CAPS_FAMILY, CAPS_DEVICE_POLYSET_POINTS, alArray);
|
||||||
DevQueryCaps( aDC, CAPS_VERTICAL_FONT_RES, 1, &lCap);
|
|
||||||
mTwipsToPixels = ((float) lCap) / (float)NSIntPointsToTwips(72);
|
|
||||||
mPixelsToTwips = 1.0f / mTwipsToPixels;
|
|
||||||
|
|
||||||
// max palette size: level out at COLOR_CUBE_SIZE
|
mTwipsToPixels = ((float)alArray[CAPS_VERTICAL_FONT_RES]) / (float)NSIntPointsToTwips(72);
|
||||||
// (or CAPS_COLORS ?)
|
mPixelsToTwips = 1.0f / mTwipsToPixels;
|
||||||
DevQueryCaps( aDC, CAPS_PHYS_COLORS, 1, &lCap);
|
|
||||||
mPaletteInfo.sizePalette = (PRUint8) (min( lCap, COLOR_CUBE_SIZE));
|
|
||||||
|
|
||||||
// erm?
|
mDepth = alArray[CAPS_COLOR_BITCOUNT];
|
||||||
mPaletteInfo.numReserved = 0;
|
mPaletteInfo.isPaletteDevice = !!(alArray[CAPS_ADDITIONAL_GRAPHICS] & CAPS_PALETTE_MANAGER);
|
||||||
|
|
||||||
DevQueryCaps( aDC, CAPS_COLOR_BITCOUNT, 1, &lCap);
|
/* OS2TODO - pref to turn off palette management should set isPaletteDevice to false */
|
||||||
mDepth = lCap;
|
|
||||||
|
|
||||||
mClientRect.x = mClientRect.y = 0;
|
if (mPaletteInfo.isPaletteDevice)
|
||||||
DevQueryCaps( aDC, CAPS_HORIZONTAL_RESOLUTION, 1, &lCap);
|
mPaletteInfo.sizePalette = 256;
|
||||||
mClientRect.width = lCap;
|
|
||||||
DevQueryCaps( aDC, CAPS_VERTICAL_RESOLUTION, 1, &lCap);
|
|
||||||
mClientRect.height = lCap;
|
|
||||||
|
|
||||||
DevQueryCaps( aDC, CAPS_TECHNOLOGY, 1, &lCap);
|
if (alArray[CAPS_COLORS] >= 20) {
|
||||||
if (lCap & CAPS_TECH_RASTER_DISPLAY) {
|
mPaletteInfo.numReserved = 20;
|
||||||
mClientRect.width = WinQuerySysValue(HWND_DESKTOP, SV_CXFULLSCREEN);
|
} else {
|
||||||
mClientRect.height = WinQuerySysValue(HWND_DESKTOP, SV_CYFULLSCREEN);
|
mPaletteInfo.numReserved = alArray[CAPS_COLORS];
|
||||||
}
|
} /* endif */
|
||||||
|
|
||||||
DeviceContextImpl::CommonInit();
|
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("component://netscape/gfx/screenmanager", &ignore);
|
||||||
|
if ( !sNumberOfScreens )
|
||||||
|
mScreenManager->GetNumberOfScreens(&sNumberOfScreens);
|
||||||
|
} // if this dc is not a print device
|
||||||
|
|
||||||
|
DeviceContextImpl::CommonInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDeviceContextOS2::ComputeClientRectUsingScreen ( nsRect* outRect )
|
nsDeviceContextOS2 :: ComputeClientRectUsingScreen ( nsRect* outRect )
|
||||||
{
|
{
|
||||||
if ( !mCachedClientRect ) {
|
if ( !mCachedClientRect ) {
|
||||||
// convert to device units
|
nsCOMPtr<nsIScreen> screen;
|
||||||
outRect->y = NSToIntRound(mClientRect.y * mDevUnitsToAppUnits);
|
FindScreen ( getter_AddRefs(screen) );
|
||||||
outRect->x = NSToIntRound(mClientRect.x * mDevUnitsToAppUnits);
|
if ( screen ) {
|
||||||
outRect->width = NSToIntRound(mClientRect.width * mDevUnitsToAppUnits);
|
PRInt32 x, y, width, height;
|
||||||
outRect->height = NSToIntRound(mClientRect.height * mDevUnitsToAppUnits);
|
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;
|
mCachedClientRect = PR_TRUE;
|
||||||
mClientRect = *outRect;
|
mClientRect = *outRect;
|
||||||
} // if we need to recompute the client rect
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*outRect = mClientRect;
|
*outRect = mClientRect;
|
||||||
|
|
||||||
@ -235,60 +244,57 @@ nsDeviceContextOS2::ComputeClientRectUsingScreen ( nsRect* outRect )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDeviceContextOS2::ComputeFullAreaUsingScreen ( nsRect* outRect )
|
nsDeviceContextOS2 :: ComputeFullAreaUsingScreen ( nsRect* outRect )
|
||||||
{
|
{
|
||||||
outRect->y = 0;
|
if ( !mCachedFullRect ) {
|
||||||
outRect->x = 0;
|
nsCOMPtr<nsIScreen> screen;
|
||||||
outRect->width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
|
FindScreen ( getter_AddRefs(screen) );
|
||||||
outRect->height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
|
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
|
} // ComputeFullRectUsingScreen
|
||||||
|
|
||||||
|
|
||||||
// Creation of other gfx objects malarky -------------------------------------
|
//
|
||||||
|
// FindScreen
|
||||||
nsresult nsDeviceContextOS2::GetDrawingSurface( nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
|
//
|
||||||
|
// Determines which screen intersects the largest area of the given surface.
|
||||||
|
//
|
||||||
|
void
|
||||||
|
nsDeviceContextOS2 :: FindScreen ( nsIScreen** outScreen )
|
||||||
{
|
{
|
||||||
if( !mSurface)
|
// optimize for the case where we only have one monitor.
|
||||||
{
|
static nsCOMPtr<nsIScreen> sPrimaryScreen;
|
||||||
nsDrawingSurface tSurface;
|
if ( !sPrimaryScreen && mScreenManager )
|
||||||
aContext.CreateDrawingSurface( nsnull, 0, tSurface);
|
mScreenManager->GetPrimaryScreen ( getter_AddRefs(sPrimaryScreen) );
|
||||||
mSurface = (nsDrawingSurfaceOS2 *) tSurface;
|
NS_IF_ADDREF(*outScreen = sPrimaryScreen.get());
|
||||||
NS_ADDREF(mSurface);
|
return;
|
||||||
}
|
} // FindScreen
|
||||||
|
|
||||||
printf("Dodgy nsDeviceContext::GetDrawingContext() called\n");
|
|
||||||
|
|
||||||
aSurface = mSurface;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::GetDeviceContextFor( nsIDeviceContextSpec *aDevice,
|
|
||||||
nsIDeviceContext *&aContext)
|
|
||||||
{
|
|
||||||
// Prolly want to clean this up xpCom-wise...
|
|
||||||
|
|
||||||
nsDeviceContextOS2 *newCX = new nsDeviceContextOS2;
|
|
||||||
nsDeviceContextSpecOS2 *spec = (nsDeviceContextSpecOS2*) aDevice;
|
|
||||||
|
|
||||||
if (!newCX)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
aContext = newCX;
|
|
||||||
NS_ADDREF(aContext);
|
|
||||||
|
|
||||||
PRTQUEUE *pq;
|
|
||||||
spec->GetPRTQUEUE( pq);
|
|
||||||
|
|
||||||
HDC hdcPrint = PrnOpenDC( pq, "Mozilla");
|
|
||||||
|
|
||||||
return newCX->Init( (nsNativeDeviceContext) hdcPrint, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* OS2TODO - NOT PORTED */
|
||||||
// Create a rendering context against our hdc for a printer
|
// Create a rendering context against our hdc for a printer
|
||||||
nsresult nsDeviceContextOS2::CreateRenderingContext( nsIRenderingContext *&aContext)
|
nsresult nsDeviceContextOS2::CreateRenderingContext( nsIRenderingContext *&aContext)
|
||||||
{
|
{
|
||||||
NS_ASSERTION( mPrintDC, "CreateRenderingContext for non-print DC");
|
NS_ASSERTION( mDC, "CreateRenderingContext for non-print DC");
|
||||||
|
|
||||||
nsIRenderingContext *pContext = new nsRenderingContextOS2;
|
nsIRenderingContext *pContext = new nsRenderingContextOS2;
|
||||||
if (!pContext)
|
if (!pContext)
|
||||||
@ -315,40 +321,26 @@ nsresult nsDeviceContextOS2::CreateRenderingContext( nsIRenderingContext *&aCont
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
HPS nsDeviceContextOS2::GetRepresentativePS() const
|
NS_IMETHODIMP nsDeviceContextOS2 :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
|
||||||
{
|
{
|
||||||
HPS hps;
|
if (nsnull == mDC)
|
||||||
|
aSupportsWidgets = PR_TRUE;
|
||||||
|
else
|
||||||
|
aSupportsWidgets = PR_FALSE;
|
||||||
|
|
||||||
if( mPrintDC == 0)
|
return NS_OK;
|
||||||
{
|
|
||||||
HWND hwnd = mWidget ? (HWND)mWidget : HWND_DESKTOP;
|
|
||||||
hps = WinGetPS( hwnd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
hps = mPS;
|
|
||||||
|
|
||||||
return hps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsDeviceContextOS2::ReleaseRepresentativePS( HPS aPS)
|
NS_IMETHODIMP nsDeviceContextOS2 :: GetCanonicalPixelScale(float &aScale) const
|
||||||
{
|
{
|
||||||
if( mPrintDC == 0)
|
aScale = mPixelScale;
|
||||||
if( !WinReleasePS( aPS))
|
return NS_OK;
|
||||||
PMERROR( "WinReleasePS (DC)");
|
|
||||||
else
|
|
||||||
/* nop */ ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metrics -------------------------------------------------------------------
|
NS_IMETHODIMP nsDeviceContextOS2 :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
|
||||||
|
|
||||||
// Note that this returns values in app units, as opposed to GetSystemAttr(),
|
|
||||||
// which uses device units.
|
|
||||||
nsresult nsDeviceContextOS2::GetScrollBarDimensions( float &aWidth, float &aHeight) const
|
|
||||||
{
|
{
|
||||||
aWidth = (float) WinQuerySysValue( HWND_DESKTOP, SV_CXVSCROLL) *
|
aWidth = ::WinQuerySysValue( HWND_DESKTOP, SV_CXVSCROLL) * mDevUnitsToAppUnits;
|
||||||
mDevUnitsToAppUnits;
|
aHeight = ::WinQuerySysValue( HWND_DESKTOP, SV_CYHSCROLL) * mDevUnitsToAppUnits;
|
||||||
aHeight = (float) WinQuerySysValue( HWND_DESKTOP, SV_CYHSCROLL) *
|
|
||||||
mDevUnitsToAppUnits;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,10 +546,161 @@ NS_IMETHODIMP nsDeviceContextOS2 :: GetSystemAttribute(nsSystemAttrID anID, Syst
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
nsresult nsDeviceContextOS2::GetDrawingSurface( nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
|
||||||
// (XXX) the screen object thinks these are in pels, duh. (jmf)
|
{
|
||||||
//
|
if (NULL == mSurface) {
|
||||||
nsresult nsDeviceContextOS2::GetDeviceSurfaceDimensions( PRInt32 &aWidth, PRInt32 &aHeight)
|
aContext.CreateDrawingSurface(nsnull, 0, mSurface);
|
||||||
|
}
|
||||||
|
|
||||||
|
aSurface = mSurface;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsDeviceContextOS2 :: CheckFontExistence(const nsString& aFontName)
|
||||||
|
{
|
||||||
|
HWND hwnd = (HWND)mWidget;
|
||||||
|
HPS hps = ::WinGetPS(hwnd);
|
||||||
|
PRBool isthere = PR_FALSE;
|
||||||
|
|
||||||
|
char fontName[FACESIZE];
|
||||||
|
aFontName.ToCString( fontName, FACESIZE);
|
||||||
|
|
||||||
|
long lWant = 0;
|
||||||
|
long lFonts = GpiQueryFonts( hps, QF_PUBLIC | QF_PRIVATE,
|
||||||
|
fontName, &lWant, 0, 0);
|
||||||
|
|
||||||
|
::WinReleasePS(hps);
|
||||||
|
|
||||||
|
if (lFonts > 0)
|
||||||
|
return NS_OK;
|
||||||
|
else
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsDeviceContextOS2::GetDepth(PRUint32& aDepth)
|
||||||
|
{
|
||||||
|
aDepth = mDepth;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsDeviceContextOS2::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||||
|
{
|
||||||
|
if (nsnull == mColorSpace) {
|
||||||
|
// See if we're dealing with an 8-bit palette device
|
||||||
|
if (8 == mDepth) {
|
||||||
|
// Create a color cube. We want to use DIB_PAL_COLORS because it's faster
|
||||||
|
// than DIB_RGB_COLORS, so make sure the indexes match that of the
|
||||||
|
// GDI physical palette
|
||||||
|
//
|
||||||
|
// Note: the image library doesn't use the reserved colors, so it doesn't
|
||||||
|
// matter what they're set to...
|
||||||
|
#ifdef XP_OS2
|
||||||
|
IL_ColorMap* colorMap = IL_NewCubeColorMap(0, 0, COLOR_CUBE_SIZE + 10);
|
||||||
|
#else
|
||||||
|
IL_RGB reserved[10];
|
||||||
|
memset(reserved, 0, sizeof(reserved));
|
||||||
|
IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 10, COLOR_CUBE_SIZE + 10);
|
||||||
|
#endif
|
||||||
|
if (nsnull == colorMap) {
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a pseudo color space
|
||||||
|
mColorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
IL_RGBBits colorRGBBits;
|
||||||
|
|
||||||
|
// Create a 24-bit color space
|
||||||
|
colorRGBBits.red_shift = 16;
|
||||||
|
colorRGBBits.red_bits = 8;
|
||||||
|
colorRGBBits.green_shift = 8;
|
||||||
|
colorRGBBits.green_bits = 8;
|
||||||
|
colorRGBBits.blue_shift = 0;
|
||||||
|
colorRGBBits.blue_bits = 8;
|
||||||
|
|
||||||
|
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nsnull == mColorSpace) {
|
||||||
|
aColorSpace = nsnull;
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the color space
|
||||||
|
aColorSpace = mColorSpace;
|
||||||
|
IL_AddRefToColorSpace(aColorSpace);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsDeviceContextOS2::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
|
||||||
|
{
|
||||||
|
aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
|
||||||
|
aPaletteInfo.numReserved = mPaletteInfo.numReserved;
|
||||||
|
|
||||||
|
if (NULL == mPaletteInfo.palette) {
|
||||||
|
IL_ColorSpace* colorSpace;
|
||||||
|
GetILColorSpace(colorSpace);
|
||||||
|
|
||||||
|
if (NI_PseudoColor == colorSpace->type) {
|
||||||
|
// Create a logical palette
|
||||||
|
#ifdef XP_OS2
|
||||||
|
PULONG aulTable;
|
||||||
|
ULONG ulCount = COLOR_CUBE_SIZE;
|
||||||
|
aulTable = (PULONG)malloc(ulCount*sizeof(ULONG));
|
||||||
|
#else
|
||||||
|
ULONG aulTable[COLOR_CUBE_SIZE+20];
|
||||||
|
ULONG ulCount = COLOR_CUBE_SIZE + 20;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XP_OS2
|
||||||
|
// First ten system colors
|
||||||
|
::GetPaletteEntries(hDefaultPalette, 0, 10, logPal->palPalEntry);
|
||||||
|
|
||||||
|
// Last ten system colors
|
||||||
|
::GetPaletteEntries(hDefaultPalette, 10, 10, &logPal->palPalEntry[COLOR_CUBE_SIZE + 10]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Now set the color cube entries.
|
||||||
|
#ifdef XP_OS2
|
||||||
|
NI_RGB* map = colorSpace->cmap.map;
|
||||||
|
#else
|
||||||
|
NI_RGB* map = colorSpace->cmap.map + 10;
|
||||||
|
#endif
|
||||||
|
#ifdef XP_OS2
|
||||||
|
for (PRInt32 i = 0; i < COLOR_CUBE_SIZE; i++, map++) {
|
||||||
|
#else
|
||||||
|
for (PRInt32 i = 10; i < COLOR_CUBE_SIZE; i++, map++) {
|
||||||
|
#endif
|
||||||
|
aulTable[i] = MK_RGB( map->red, map->green, map->blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mPaletteInfo.isPaletteDevice) {
|
||||||
|
// Create a GPI palette
|
||||||
|
mPaletteInfo.palette = (void*)::GpiCreatePalette( (HAB)0, NULL, LCOLF_CONSECRGB, ulCount, aulTable );
|
||||||
|
free(aulTable);
|
||||||
|
} else {
|
||||||
|
mPaletteInfo.palette = (void*)aulTable;
|
||||||
|
mPaletteInfo.sizePalette = ulCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IL_ReleaseColorSpace(colorSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
aPaletteInfo.palette = mPaletteInfo.palette;
|
||||||
|
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsDeviceContextOS2 :: ConvertPixel(nscolor aColor, PRUint32 & aPixel)
|
||||||
|
{
|
||||||
|
aPixel = aColor;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsDeviceContextOS2 :: GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
|
||||||
{
|
{
|
||||||
if ( mSpec )
|
if ( mSpec )
|
||||||
{
|
{
|
||||||
@ -575,7 +718,7 @@ nsresult nsDeviceContextOS2::GetDeviceSurfaceDimensions( PRInt32 &aWidth, PRInt3
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDeviceContextOS2::GetRect(nsRect &aRect)
|
NS_IMETHODIMP nsDeviceContextOS2 :: GetRect(nsRect &aRect)
|
||||||
{
|
{
|
||||||
if ( mSpec )
|
if ( mSpec )
|
||||||
{
|
{
|
||||||
@ -591,7 +734,8 @@ NS_IMETHODIMP nsDeviceContextOS2::GetRect(nsRect &aRect)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::GetClientRect(nsRect &aRect)
|
|
||||||
|
NS_IMETHODIMP nsDeviceContextOS2 :: GetClientRect(nsRect &aRect)
|
||||||
{
|
{
|
||||||
if ( mSpec )
|
if ( mSpec )
|
||||||
{
|
{
|
||||||
@ -607,46 +751,23 @@ nsresult nsDeviceContextOS2::GetClientRect(nsRect &aRect)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::GetDepth( PRUint32& aDepth)
|
NS_IMETHODIMP nsDeviceContextOS2 :: GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||||
|
nsIDeviceContext *&aContext)
|
||||||
{
|
{
|
||||||
aDepth = mDepth;
|
PRTQUEUE *pq;
|
||||||
return NS_OK;
|
|
||||||
|
aContext = new nsDeviceContextOS2();
|
||||||
|
|
||||||
|
((nsDeviceContextOS2 *)aContext)->mSpec = aDevice;
|
||||||
|
NS_ADDREF(aDevice);
|
||||||
|
|
||||||
|
((nsDeviceContextSpecOS2 *)aDevice)->GetPRTQUEUE(pq);
|
||||||
|
|
||||||
|
HDC dc = PrnOpenDC(pq, "Mozilla");
|
||||||
|
|
||||||
|
return ((nsDeviceContextOS2 *)aContext)->Init((nsNativeDeviceContext)dc, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yuck...
|
|
||||||
nsresult nsDeviceContextOS2::SupportsNativeWidgets( PRBool &aSupportsWidgets)
|
|
||||||
{
|
|
||||||
aSupportsWidgets = (mPrintDC == 0) ? PR_TRUE : PR_FALSE;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::GetCanonicalPixelScale( float &aScale) const
|
|
||||||
{
|
|
||||||
aScale = mPixelScale;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fonts ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Rather unfortunate place for this method...
|
|
||||||
nsresult nsDeviceContextOS2::CheckFontExistence( const nsString &aFontName)
|
|
||||||
{
|
|
||||||
HPS hps = GetRepresentativePS();
|
|
||||||
|
|
||||||
char fontName[ FACESIZE];
|
|
||||||
aFontName.ToCString( fontName, FACESIZE);
|
|
||||||
|
|
||||||
long lWant = 0;
|
|
||||||
long lFonts = GpiQueryFonts( hps, QF_PUBLIC | QF_PRIVATE,
|
|
||||||
fontName, &lWant, 0, 0);
|
|
||||||
|
|
||||||
ReleaseRepresentativePS( hps);
|
|
||||||
|
|
||||||
return lFonts > 0 ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Font setup - defaults aren't terribly helpful; this may be no better!
|
|
||||||
nsresult nsDeviceContextOS2::CreateFontAliasTable()
|
nsresult nsDeviceContextOS2::CreateFontAliasTable()
|
||||||
{
|
{
|
||||||
nsresult result = NS_OK;
|
nsresult result = NS_OK;
|
||||||
@ -683,105 +804,13 @@ nsresult nsDeviceContextOS2::CreateFontAliasTable()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colourspaces and palettes -------------------------------------------------
|
|
||||||
|
|
||||||
// Override these so we can use palette manager
|
|
||||||
nsresult nsDeviceContextOS2::GetILColorSpace( IL_ColorSpace *&aColorSpace)
|
|
||||||
{
|
|
||||||
if( !mColorSpace)
|
|
||||||
{
|
|
||||||
// !! Might want to do something funky for 4bpp displays
|
|
||||||
|
|
||||||
// See if we're dealing with an 8-bit palette device
|
|
||||||
if( (8 == mDepth) && mPaletteInfo.isPaletteDevice)
|
|
||||||
{
|
|
||||||
IL_ColorMap *cMap = IL_NewCubeColorMap( 0, 0, COLOR_CUBE_SIZE);
|
|
||||||
if( !cMap)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
// Create a pseudo color space
|
|
||||||
mColorSpace = IL_CreatePseudoColorSpace( cMap, 8, 8);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IL_RGBBits colorRGBBits;
|
|
||||||
|
|
||||||
// Create a 24-bit color space
|
|
||||||
colorRGBBits.red_shift = 16;
|
|
||||||
colorRGBBits.red_bits = 8;
|
|
||||||
colorRGBBits.green_shift = 8;
|
|
||||||
colorRGBBits.green_bits = 8;
|
|
||||||
colorRGBBits.blue_shift = 0;
|
|
||||||
colorRGBBits.blue_bits = 8;
|
|
||||||
|
|
||||||
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !mColorSpace)
|
|
||||||
{
|
|
||||||
aColorSpace = nsnull;
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the color space
|
|
||||||
aColorSpace = mColorSpace;
|
|
||||||
IL_AddRefToColorSpace( aColorSpace);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::GetPaletteInfo( nsPaletteInfo& aPaletteInfo)
|
|
||||||
{
|
|
||||||
aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
|
|
||||||
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
|
|
||||||
aPaletteInfo.numReserved = mPaletteInfo.numReserved;
|
|
||||||
|
|
||||||
nsresult rc = NS_OK;
|
|
||||||
|
|
||||||
SetupColorMaps();
|
|
||||||
|
|
||||||
aPaletteInfo.palette = mPaletteInfo.palette;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::GetPalette( nsIPaletteOS2 *&aPalette)
|
|
||||||
{
|
|
||||||
nsresult rc = SetupColorMaps();
|
|
||||||
aPalette = mPalette;
|
|
||||||
NS_ADDREF( aPalette);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsDeviceContextOS2::SetupColorMaps()
|
|
||||||
{
|
|
||||||
nsresult rc = NS_OK;
|
|
||||||
if( !mPalette)
|
|
||||||
{
|
|
||||||
// Share a single palette between all screen instances; printers need
|
|
||||||
// a separate palette for compatability reasons.
|
|
||||||
if( mPrintDC) rc = NS_CreatePalette( this, mPalette);
|
|
||||||
else mPalette = gModuleData.GetUIPalette( this);
|
|
||||||
|
|
||||||
if( rc == NS_OK)
|
|
||||||
rc = mPalette->GetNSPalette( mPaletteInfo.palette);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDeviceContextOS2::ConvertPixel(nscolor aColor, PRUint32 & aPixel)
|
|
||||||
{
|
|
||||||
printf( "Alert: nsDeviceContext::ConvertPixel called\n");
|
|
||||||
aPixel = aColor;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Printing ------------------------------------------------------------------
|
// Printing ------------------------------------------------------------------
|
||||||
nsresult nsDeviceContextOS2::BeginDocument()
|
nsresult nsDeviceContextOS2::BeginDocument()
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mPrintDC, "BeginDocument for non-print DC");
|
NS_ASSERTION(mDC, "BeginDocument for non-print DC");
|
||||||
if( mPrintState == nsPrintState_ePreBeginDoc)
|
if( mPrintState == nsPrintState_ePreBeginDoc)
|
||||||
{
|
{
|
||||||
PrnStartJob( mPrintDC, "Warpzilla NGLayout job");
|
PrnStartJob( mDC, "Warpzilla NGLayout job");
|
||||||
printf( "BeginDoc\n");
|
printf( "BeginDoc\n");
|
||||||
mPrintState = nsPrintState_eBegunDoc;
|
mPrintState = nsPrintState_eBegunDoc;
|
||||||
}
|
}
|
||||||
@ -790,7 +819,7 @@ nsresult nsDeviceContextOS2::BeginDocument()
|
|||||||
|
|
||||||
nsresult nsDeviceContextOS2::EndDocument()
|
nsresult nsDeviceContextOS2::EndDocument()
|
||||||
{
|
{
|
||||||
PrnEndJob( mPrintDC);
|
PrnEndJob( mDC);
|
||||||
mPrintState = nsPrintState_ePreBeginDoc;
|
mPrintState = nsPrintState_ePreBeginDoc;
|
||||||
printf("EndDoc\n");
|
printf("EndDoc\n");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -802,7 +831,7 @@ nsresult nsDeviceContextOS2::BeginPage()
|
|||||||
mPrintState = nsPrintState_eBegunFirstPage;
|
mPrintState = nsPrintState_eBegunFirstPage;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PrnNewPage( mPrintDC);
|
PrnNewPage( mDC);
|
||||||
printf("NewPage");
|
printf("NewPage");
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -816,7 +845,7 @@ nsresult nsDeviceContextOS2::EndPage()
|
|||||||
|
|
||||||
BOOL nsDeviceContextOS2::isPrintDC()
|
BOOL nsDeviceContextOS2::isPrintDC()
|
||||||
{
|
{
|
||||||
if ( mPrintDC == nsnull )
|
if ( mDC == nsnull )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -1,147 +1,123 @@
|
|||||||
/*
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
* 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"
|
* The contents of this file are subject to the Netscape Public
|
||||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
* License Version 1.1 (the "License"); you may not use this file
|
||||||
* License for the specific language governing rights and limitations
|
* except in compliance with the License. You may obtain a copy of
|
||||||
* under the License.
|
* the License at http://www.mozilla.org/NPL/
|
||||||
*
|
*
|
||||||
* The Original Code is the Mozilla OS/2 libraries.
|
* 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 Initial Developer of the Original Code is John Fairhurst,
|
* The Original Code is mozilla.org code.
|
||||||
* <john_fairhurst@iname.com>. Portions created by John Fairhurst are
|
|
||||||
* Copyright (C) 1999 John Fairhurst. All Rights Reserved.
|
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* The Initial Developer of the Original Code is Netscape
|
||||||
* This Original Code has been modified by IBM Corporation.
|
* Communications Corporation. Portions created by Netscape are
|
||||||
* Modifications made by IBM described herein are
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||||
* Copyright (c) International Business Machines
|
* Rights Reserved.
|
||||||
* Corporation, 2000
|
|
||||||
*
|
*
|
||||||
* Modifications to Mozilla code or documentation
|
* Contributor(s):
|
||||||
* 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
|
|
||||||
* 05/31/2000 IBM Corp. Print changes.
|
|
||||||
* 06/07/2000 IBM Corp. Corrected querying of screen and client sizes
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _nsDeviceContextOS2_h
|
#ifndef nsDeviceContextOS2_h___
|
||||||
#define _nsDeviceContextOS2_h
|
#define nsDeviceContextOS2_h___
|
||||||
|
|
||||||
#include "nsDeviceContext.h"
|
#include "nsDeviceContext.h"
|
||||||
#include "nsRenderingContextOS2.h"
|
#include "nsIScreenManager.h"
|
||||||
|
#define INCL_GPI
|
||||||
|
#define INCL_PM
|
||||||
|
#define INCL_DOS
|
||||||
|
#include <os2.h>
|
||||||
|
#include "libprint.h"
|
||||||
|
|
||||||
// Device contexts are either for windows or for printers.
|
class nsIScreen;
|
||||||
// If the former, the DeviceContextImpl member mWidget is set.
|
|
||||||
// If the latter, the mPrintDC member here is set.
|
|
||||||
// (yes, I know: eventually want to split these guys up)
|
|
||||||
|
|
||||||
class nsIPaletteOS2;
|
|
||||||
class nsDrawingSurfaceOS2;
|
|
||||||
|
|
||||||
class nsDeviceContextOS2 : public DeviceContextImpl
|
class nsDeviceContextOS2 : public DeviceContextImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsDeviceContextOS2();
|
nsDeviceContextOS2();
|
||||||
|
|
||||||
NS_IMETHOD Init( nsNativeWidget aWidget);
|
NS_IMETHOD Init(nsNativeWidget aWidget);
|
||||||
|
|
||||||
NS_IMETHOD CreateRenderingContext( nsIRenderingContext *&aContext);
|
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
|
||||||
|
|
||||||
NS_IMETHOD SupportsNativeWidgets( PRBool &aSupportsWidgets);
|
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
|
||||||
|
|
||||||
NS_IMETHOD GetCanonicalPixelScale( float &aScale) const;
|
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const;
|
||||||
|
|
||||||
NS_IMETHOD GetScrollBarDimensions( float &aWidth, float &aHeight) const;
|
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
|
||||||
NS_IMETHOD GetSystemAttribute( nsSystemAttrID anID, SystemAttrStruct *aInfo) const;
|
NS_IMETHOD GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const;
|
||||||
|
|
||||||
// get a low level drawing surface for rendering. the rendering context
|
//get a low level drawing surface for rendering. the rendering context
|
||||||
// that is passed in is used to create the drawing surface if there isn't
|
//that is passed in is used to create the drawing surface if there isn't
|
||||||
// already one in the device context. the drawing surface is then cached
|
//already one in the device context. the drawing surface is then cached
|
||||||
// in the device context for re-use.
|
//in the device context for re-use.
|
||||||
NS_IMETHOD GetDrawingSurface( nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||||
|
|
||||||
NS_IMETHOD CheckFontExistence( const nsString &aFontName);
|
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||||
|
|
||||||
NS_IMETHOD GetDepth( PRUint32 &aDepth);
|
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||||
|
|
||||||
NS_IMETHOD GetILColorSpace( IL_ColorSpace*& aColorSpace);
|
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||||
|
|
||||||
NS_IMETHOD GetPaletteInfo( nsPaletteInfo &);
|
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&);
|
||||||
|
|
||||||
NS_IMETHOD ConvertPixel( nscolor aColor, PRUint32 & aPixel);
|
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||||
|
|
||||||
NS_IMETHOD GetDeviceSurfaceDimensions( PRInt32 &aWidth, PRInt32 &aHeight);
|
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||||
|
NS_IMETHOD GetRect(nsRect &aRect);
|
||||||
|
NS_IMETHOD GetClientRect(nsRect &aRect);
|
||||||
|
|
||||||
NS_IMETHOD GetRect(nsRect &aRect);
|
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||||
|
nsIDeviceContext *&aContext);
|
||||||
|
|
||||||
NS_IMETHOD GetClientRect(nsRect &aRect);
|
NS_IMETHOD BeginDocument(void);
|
||||||
|
NS_IMETHOD EndDocument(void);
|
||||||
|
|
||||||
NS_IMETHOD GetDeviceContextFor( nsIDeviceContextSpec *aDevice,
|
NS_IMETHOD BeginPage(void);
|
||||||
nsIDeviceContext *&aContext);
|
NS_IMETHOD EndPage(void);
|
||||||
|
|
||||||
NS_IMETHOD BeginDocument(void);
|
protected:
|
||||||
NS_IMETHOD EndDocument(void);
|
virtual ~nsDeviceContextOS2();
|
||||||
|
void CommonInit(HDC aDC);
|
||||||
|
nsresult Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext);
|
||||||
|
void FindScreen ( nsIScreen** outScreen ) ;
|
||||||
|
void ComputeClientRectUsingScreen ( nsRect* outRect ) ;
|
||||||
|
void ComputeFullAreaUsingScreen ( nsRect* outRect ) ;
|
||||||
|
|
||||||
NS_IMETHOD BeginPage(void);
|
PRBool mCachedClientRect;
|
||||||
NS_IMETHOD EndPage(void);
|
PRBool mCachedFullRect;
|
||||||
|
|
||||||
// XXXX Copped from GTK version to remove warning about hidden virtual; nothing in Windows
|
nsDrawingSurface mSurface;
|
||||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aView,aContext));}
|
PRUint32 mDepth; // bit depth of device
|
||||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aWidget,aContext));}
|
nsPaletteInfo mPaletteInfo;
|
||||||
|
float mPixelScale;
|
||||||
|
PRInt32 mWidth;
|
||||||
|
PRInt32 mHeight;
|
||||||
|
nsRect mClientRect;
|
||||||
|
nsIDeviceContextSpec *mSpec;
|
||||||
|
|
||||||
// OS2 specific methods
|
nsCOMPtr<nsIScreenManager> mScreenManager;
|
||||||
public:
|
static PRUint32 sNumberOfScreens;
|
||||||
// Call to ensure colour table/palette is loaded and ready.
|
|
||||||
nsresult SetupColorMaps();
|
|
||||||
// Get the palette object for the device, used to pick colours.
|
|
||||||
// Release when done.
|
|
||||||
nsresult GetPalette( nsIPaletteOS2 *&apalette);
|
|
||||||
// Init from a HDC for printing purposes
|
|
||||||
void CommonInit(HDC aDC);
|
|
||||||
nsresult Init( nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext);
|
|
||||||
|
|
||||||
// Needed by the fontmetrics - can't rely on having a widget.
|
public:
|
||||||
HPS GetRepresentativePS() const;
|
HDC mDC;
|
||||||
void ReleaseRepresentativePS( HPS aPS);
|
HPS mPS;
|
||||||
BOOL isPrintDC();
|
|
||||||
|
|
||||||
protected:
|
static PRBool gRound;
|
||||||
virtual ~nsDeviceContextOS2();
|
static int PrefChanged(const char* aPref, void* aClosure);
|
||||||
|
|
||||||
virtual nsresult CreateFontAliasTable();
|
enum nsPrintState
|
||||||
|
{
|
||||||
|
nsPrintState_ePreBeginDoc,
|
||||||
|
nsPrintState_eBegunDoc,
|
||||||
|
nsPrintState_eBegunFirstPage,
|
||||||
|
nsPrintState_eEndedDoc
|
||||||
|
} mPrintState;
|
||||||
|
|
||||||
void ComputeClientRectUsingScreen ( nsRect* outRect ) ;
|
BOOL isPrintDC();
|
||||||
void ComputeFullAreaUsingScreen ( nsRect* outRect ) ;
|
nsresult nsDeviceContextOS2::CreateFontAliasTable();
|
||||||
|
|
||||||
PRBool mCachedClientRect;
|
|
||||||
PRBool mCachedFullRect;
|
|
||||||
|
|
||||||
nsDrawingSurfaceOS2 *mSurface;
|
|
||||||
PRUint32 mDepth; // bit depth of device
|
|
||||||
nsPaletteInfo mPaletteInfo;
|
|
||||||
float mPixelScale;
|
|
||||||
nsIPaletteOS2 *mPalette;
|
|
||||||
PRInt32 mWidth;
|
|
||||||
PRInt32 mHeight;
|
|
||||||
nsRect mClientRect;
|
|
||||||
nsIDeviceContextSpec *mSpec;
|
|
||||||
HDC mPrintDC; // PrintDC. Owned by libprint.
|
|
||||||
HPS mPS; // PrintPS.
|
|
||||||
|
|
||||||
enum nsPrintState
|
|
||||||
{
|
|
||||||
nsPrintState_ePreBeginDoc,
|
|
||||||
nsPrintState_eBegunDoc,
|
|
||||||
nsPrintState_eBegunFirstPage,
|
|
||||||
nsPrintState_eEndedDoc
|
|
||||||
} mPrintState;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsDeviceContextOS2_h__ */
|
#endif /* nsDeviceContextOS2_h___ */
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
#include "nsDrawingSurfaceOS2.h"
|
#include "nsDrawingSurfaceOS2.h"
|
||||||
#include "nsFontMetricsOS2.h"
|
#include "nsFontMetricsOS2.h"
|
||||||
#include "nsPaletteOS2.h"
|
|
||||||
|
|
||||||
// Base class -- fonts, palette and xpcom -----------------------------------
|
// Base class -- fonts, palette and xpcom -----------------------------------
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ NS_IMPL_ISUPPORTS(nsDrawingSurfaceOS2, NS_GET_IID(nsIDrawingSurface))
|
|||||||
// do testing with, and 0 is, of course, LCID_DEFAULT.
|
// do testing with, and 0 is, of course, LCID_DEFAULT.
|
||||||
|
|
||||||
nsDrawingSurfaceOS2::nsDrawingSurfaceOS2()
|
nsDrawingSurfaceOS2::nsDrawingSurfaceOS2()
|
||||||
: mNextID(2), mTopID(1), mPalette(0), mPS(0)
|
: mNextID(2), mTopID(1), mPS(0)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
mHTFonts = new nsHashtable;
|
mHTFonts = new nsHashtable;
|
||||||
@ -43,8 +42,6 @@ nsDrawingSurfaceOS2::nsDrawingSurfaceOS2()
|
|||||||
|
|
||||||
nsDrawingSurfaceOS2::~nsDrawingSurfaceOS2()
|
nsDrawingSurfaceOS2::~nsDrawingSurfaceOS2()
|
||||||
{
|
{
|
||||||
// release palette; no harm if it's already been done by a subclass
|
|
||||||
DeselectPalette();
|
|
||||||
DisposeFonts();
|
DisposeFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,23 +96,6 @@ void nsDrawingSurfaceOS2::FlushFontCache()
|
|||||||
// leave mTopID where it is.
|
// leave mTopID where it is.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Palette
|
|
||||||
void nsDrawingSurfaceOS2::SetPalette( nsIPaletteOS2 *aPalette)
|
|
||||||
{
|
|
||||||
NS_IF_RELEASE(mPalette);
|
|
||||||
mPalette = aPalette;
|
|
||||||
NS_ADDREF(mPalette);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsDrawingSurfaceOS2::DeselectPalette()
|
|
||||||
{
|
|
||||||
if( mPalette)
|
|
||||||
{
|
|
||||||
mPalette->Deselect( mPS);
|
|
||||||
NS_RELEASE(mPalette); // this nulls out mPalette
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// yuck.
|
// yuck.
|
||||||
nsresult nsDrawingSurfaceOS2::GetBitmap( HBITMAP &aBitmap)
|
nsresult nsDrawingSurfaceOS2::GetBitmap( HBITMAP &aBitmap)
|
||||||
{
|
{
|
||||||
@ -203,7 +183,6 @@ nsOffscreenSurface::~nsOffscreenSurface()
|
|||||||
PMERROR( "GpiSetBitmap");
|
PMERROR( "GpiSetBitmap");
|
||||||
if( !GpiDeleteBitmap( mBitmap))
|
if( !GpiDeleteBitmap( mBitmap))
|
||||||
PMERROR( "GpiDeleteBitmap");
|
PMERROR( "GpiDeleteBitmap");
|
||||||
DeselectPalette();
|
|
||||||
//
|
//
|
||||||
// Don't need to do this because the PS is a micro-one.
|
// Don't need to do this because the PS is a micro-one.
|
||||||
//
|
//
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
class nsHashtable;
|
class nsHashtable;
|
||||||
class nsIWidget;
|
class nsIWidget;
|
||||||
class nsIPaletteOS2;
|
|
||||||
|
|
||||||
// These were called `drawables' in os2fe.
|
// These were called `drawables' in os2fe.
|
||||||
//
|
//
|
||||||
@ -55,7 +54,6 @@ class nsDrawingSurfaceOS2 : public nsIDrawingSurface
|
|||||||
nsHashtable *mHTFonts; // cache of fonthandle to lcid
|
nsHashtable *mHTFonts; // cache of fonthandle to lcid
|
||||||
long mNextID; // next lcid to allocate
|
long mNextID; // next lcid to allocate
|
||||||
long mTopID; // highest used lcid
|
long mTopID; // highest used lcid
|
||||||
nsIPaletteOS2 *mPalette; // palette
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
nsDrawingSurfaceOS2();
|
nsDrawingSurfaceOS2();
|
||||||
@ -71,13 +69,10 @@ class nsDrawingSurfaceOS2 : public nsIDrawingSurface
|
|||||||
void SelectFont( nsIFontMetrics *metrics);
|
void SelectFont( nsIFontMetrics *metrics);
|
||||||
void FlushFontCache();
|
void FlushFontCache();
|
||||||
|
|
||||||
void SetPalette( nsIPaletteOS2 *aPalette);
|
|
||||||
|
|
||||||
NS_IMETHOD GetBitmap( HBITMAP &aBitmap); // yuck (for blender, may go)
|
NS_IMETHOD GetBitmap( HBITMAP &aBitmap); // yuck (for blender, may go)
|
||||||
NS_IMETHOD RequiresInvertedMask( PRBool *aBool); // double yuck (images)
|
NS_IMETHOD RequiresInvertedMask( PRBool *aBool); // double yuck (images)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DeselectPalette();
|
|
||||||
void DisposeFonts(); // MUST be called before disposing of PS
|
void DisposeFonts(); // MUST be called before disposing of PS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
void PMERROR(const char *str);
|
void PMERROR(const char *str);
|
||||||
|
|
||||||
class nsString;
|
class nsString;
|
||||||
class nsIPaletteOS2;
|
|
||||||
class nsIDeviceContext;
|
class nsIDeviceContext;
|
||||||
|
|
||||||
// Module data
|
// Module data
|
||||||
@ -67,12 +66,6 @@ struct nsGfxModuleData
|
|||||||
// XXX XXX XXX end hack
|
// XXX XXX XXX end hack
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
// This addref's
|
|
||||||
nsIPaletteOS2 *GetUIPalette( nsIDeviceContext *aContext);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
nsIPaletteOS2 *uiPalette;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern nsGfxModuleData gModuleData;
|
extern nsGfxModuleData gModuleData;
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include "nsDeviceContextOS2.h"
|
#include "nsDeviceContextOS2.h"
|
||||||
#include "nsRegionOS2.h"
|
#include "nsRegionOS2.h"
|
||||||
#include "nsBlender.h"
|
#include "nsBlender.h"
|
||||||
#include "nsPaletteOS2.h"
|
|
||||||
#include "nsDeviceContextSpecOS2.h"
|
#include "nsDeviceContextSpecOS2.h"
|
||||||
#include "nsDeviceContextSpecFactoryO.h"
|
#include "nsDeviceContextSpecFactoryO.h"
|
||||||
//#include "nsScriptableRegion.h"
|
//#include "nsScriptableRegion.h"
|
||||||
@ -285,7 +284,7 @@ void PMERROR( const char *api)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsGfxModuleData::nsGfxModuleData() : hModResources(0), hpsScreen(0),
|
nsGfxModuleData::nsGfxModuleData() : hModResources(0), hpsScreen(0),
|
||||||
lDisplayDepth(0), uiPalette(0)
|
lDisplayDepth(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void nsGfxModuleData::Init()
|
void nsGfxModuleData::Init()
|
||||||
@ -336,18 +335,6 @@ nsGfxModuleData::~nsGfxModuleData()
|
|||||||
if( hModResources)
|
if( hModResources)
|
||||||
DosFreeModule( hModResources);
|
DosFreeModule( hModResources);
|
||||||
WinReleasePS( hpsScreen);
|
WinReleasePS( hpsScreen);
|
||||||
|
|
||||||
NS_IF_RELEASE(uiPalette);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIPaletteOS2 *nsGfxModuleData::GetUIPalette( nsIDeviceContext *aContext)
|
|
||||||
{
|
|
||||||
if( !uiPalette)
|
|
||||||
NS_CreatePalette( aContext, uiPalette);
|
|
||||||
|
|
||||||
NS_ADDREF(uiPalette);
|
|
||||||
|
|
||||||
return uiPalette;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsGfxModuleData gModuleData;
|
nsGfxModuleData gModuleData;
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
#include "nsFontMetricsOS2.h"
|
#include "nsFontMetricsOS2.h"
|
||||||
#include "nsIFontMetrics.h"
|
#include "nsIFontMetrics.h"
|
||||||
#include "nsTransform2D.h"
|
#include "nsTransform2D.h"
|
||||||
#include "nsPaletteOS2.h"
|
|
||||||
#include "nsRegionOS2.h"
|
#include "nsRegionOS2.h"
|
||||||
#include "nsGfxCIID.h"
|
#include "nsGfxCIID.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
@ -215,7 +214,6 @@ nsRenderingContextOS2::nsRenderingContextOS2()
|
|||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
|
|
||||||
mContext = nsnull;
|
mContext = nsnull;
|
||||||
mPalette = nsnull;
|
|
||||||
mSurface = nsnull;
|
mSurface = nsnull;
|
||||||
mFrontSurface = nsnull;
|
mFrontSurface = nsnull;
|
||||||
mColor = NS_RGB( 0, 0, 0);
|
mColor = NS_RGB( 0, 0, 0);
|
||||||
@ -254,7 +252,6 @@ nsRenderingContextOS2::~nsRenderingContextOS2()
|
|||||||
// Release surfaces and the palette
|
// Release surfaces and the palette
|
||||||
NS_IF_RELEASE(mFrontSurface);
|
NS_IF_RELEASE(mFrontSurface);
|
||||||
NS_IF_RELEASE(mSurface);
|
NS_IF_RELEASE(mSurface);
|
||||||
NS_IF_RELEASE(mPalette);
|
|
||||||
NS_IF_RELEASE(mFontMetrics);
|
NS_IF_RELEASE(mFontMetrics);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,10 +274,14 @@ nsresult nsRenderingContextOS2::Init( nsIDeviceContext *aContext,
|
|||||||
mSurface = surf;
|
mSurface = surf;
|
||||||
NS_ADDREF(mSurface);
|
NS_ADDREF(mSurface);
|
||||||
|
|
||||||
|
mDCOwner = aWindow;
|
||||||
|
|
||||||
// Grab another reference to the onscreen for later uniformity
|
// Grab another reference to the onscreen for later uniformity
|
||||||
mFrontSurface = mSurface;
|
mFrontSurface = mSurface;
|
||||||
NS_ADDREF(mFrontSurface);
|
NS_ADDREF(mFrontSurface);
|
||||||
|
|
||||||
|
mContext->GetGammaTable(mGammaTable);
|
||||||
|
|
||||||
return CommonInit();
|
return CommonInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,11 +310,29 @@ nsresult nsRenderingContextOS2::CommonInit()
|
|||||||
mTMatrix.AddScale( app2dev, app2dev);
|
mTMatrix.AddScale( app2dev, app2dev);
|
||||||
mContext->GetDevUnitsToAppUnits( mP2T);
|
mContext->GetDevUnitsToAppUnits( mP2T);
|
||||||
|
|
||||||
((nsDeviceContextOS2 *) mContext)->GetPalette( mPalette);
|
// If this is a palette device, then select and realize the palette
|
||||||
|
nsPaletteInfo palInfo;
|
||||||
|
mContext->GetPaletteInfo(palInfo);
|
||||||
|
|
||||||
mPalette->Select( mSurface->mPS, mContext);
|
if (palInfo.isPaletteDevice && palInfo.palette)
|
||||||
mSurface->SetPalette( mPalette);
|
{
|
||||||
return NS_OK;
|
ULONG cclr;
|
||||||
|
// Select the palette in the background
|
||||||
|
::GpiSelectPalette(mSurface->mPS, (HPAL)palInfo.palette);
|
||||||
|
::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr);
|
||||||
|
} else if (!palInfo.isPaletteDevice && palInfo.palette) {
|
||||||
|
GpiCreateLogColorTable( mSurface->mPS, LCOL_RESET | LCOL_PURECOLOR,
|
||||||
|
LCOLF_CONSECRGB, 0,
|
||||||
|
palInfo.sizePalette, (PLONG) palInfo.palette);
|
||||||
|
free(palInfo.palette);
|
||||||
|
palInfo.palette = nsnull;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GpiCreateLogColorTable( mSurface->mPS, LCOL_PURECOLOR,
|
||||||
|
LCOLF_RGB, 0, 0, 0);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PS & drawing surface management -----------------------------------------
|
// PS & drawing surface management -----------------------------------------
|
||||||
@ -326,8 +345,28 @@ nsresult nsRenderingContextOS2::SelectOffScreenDrawingSurface( nsDrawingSurface
|
|||||||
{
|
{
|
||||||
NS_IF_RELEASE(mSurface);
|
NS_IF_RELEASE(mSurface);
|
||||||
mSurface = (nsDrawingSurfaceOS2 *) aSurface;
|
mSurface = (nsDrawingSurfaceOS2 *) aSurface;
|
||||||
mPalette->Select( mSurface->mPS, mContext);
|
// If this is a palette device, then select and realize the palette
|
||||||
mSurface->SetPalette( mPalette);
|
nsPaletteInfo palInfo;
|
||||||
|
mContext->GetPaletteInfo(palInfo);
|
||||||
|
|
||||||
|
if (palInfo.isPaletteDevice && palInfo.palette)
|
||||||
|
{
|
||||||
|
ULONG cclr;
|
||||||
|
// Select the palette in the background
|
||||||
|
::GpiSelectPalette(mSurface->mPS, (HPAL)palInfo.palette);
|
||||||
|
::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr);
|
||||||
|
} else if (!palInfo.isPaletteDevice && palInfo.palette) {
|
||||||
|
GpiCreateLogColorTable( mSurface->mPS, LCOL_RESET | LCOL_PURECOLOR,
|
||||||
|
LCOLF_CONSECRGB, 0,
|
||||||
|
palInfo.sizePalette, (PLONG) palInfo.palette);
|
||||||
|
free(palInfo.palette);
|
||||||
|
palInfo.palette = nsnull;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GpiCreateLogColorTable( mSurface->mPS, LCOL_PURECOLOR,
|
||||||
|
LCOLF_RGB, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // deselect current offscreen...
|
else // deselect current offscreen...
|
||||||
{
|
{
|
||||||
@ -832,7 +871,10 @@ void nsRenderingContextOS2::SetupDrawingColor( BOOL bForce)
|
|||||||
LINEBUNDLE lineBundle;
|
LINEBUNDLE lineBundle;
|
||||||
|
|
||||||
|
|
||||||
long lColor = mPalette->GetGPIColor( mContext, mSurface->mPS, mColor);
|
long gcolor = MK_RGB( mGammaTable[NS_GET_R(mColor)],
|
||||||
|
mGammaTable[NS_GET_G(mColor)],
|
||||||
|
mGammaTable[NS_GET_B(mColor)]);
|
||||||
|
long lColor = GpiQueryColorIndex( mSurface->mPS, 0, gcolor);
|
||||||
|
|
||||||
long lLineFlags = LBB_COLOR;
|
long lLineFlags = LBB_COLOR;
|
||||||
long lAreaFlags = ABB_COLOR;
|
long lAreaFlags = ABB_COLOR;
|
||||||
@ -841,21 +883,6 @@ void nsRenderingContextOS2::SetupDrawingColor( BOOL bForce)
|
|||||||
lineBundle.lColor = lColor;
|
lineBundle.lColor = lColor;
|
||||||
|
|
||||||
|
|
||||||
if ( (((nsDeviceContextOS2 *) mContext)->isPrintDC() ) == 1)
|
|
||||||
{
|
|
||||||
|
|
||||||
areaBundle.lBackColor = 0x00FFFFFF; //OS2TODO
|
|
||||||
lineBundle.lBackColor = 0x00FFFFFF;
|
|
||||||
|
|
||||||
areaBundle.usMixMode = FM_LEAVEALONE;
|
|
||||||
areaBundle.usBackMixMode = BM_LEAVEALONE;
|
|
||||||
|
|
||||||
|
|
||||||
lLineFlags = lLineFlags | LBB_BACK_COLOR ;
|
|
||||||
lAreaFlags = lAreaFlags | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpiSetAttrs( mSurface->mPS, PRIM_LINE,lLineFlags, 0, (PBUNDLE)&lineBundle);
|
GpiSetAttrs( mSurface->mPS, PRIM_LINE,lLineFlags, 0, (PBUNDLE)&lineBundle);
|
||||||
|
|
||||||
GpiSetAttrs( mSurface->mPS, PRIM_AREA,lAreaFlags, 0, (PBUNDLE)&areaBundle);
|
GpiSetAttrs( mSurface->mPS, PRIM_AREA,lAreaFlags, 0, (PBUNDLE)&areaBundle);
|
||||||
@ -897,7 +924,10 @@ void nsRenderingContextOS2::SetupFontAndColor( BOOL bForce)
|
|||||||
|
|
||||||
CHARBUNDLE cBundle;
|
CHARBUNDLE cBundle;
|
||||||
|
|
||||||
cBundle.lColor = mPalette->GetGPIColor( mContext, mSurface->mPS, mColor);
|
long gcolor = MK_RGB( mGammaTable[NS_GET_R(mColor)],
|
||||||
|
mGammaTable[NS_GET_G(mColor)],
|
||||||
|
mGammaTable[NS_GET_B(mColor)]);
|
||||||
|
cBundle.lColor = GpiQueryColorIndex( mSurface->mPS, 0, gcolor);
|
||||||
|
|
||||||
cBundle.usMixMode = FM_OVERPAINT;
|
cBundle.usMixMode = FM_OVERPAINT;
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define _nsRenderingContextOS2_h
|
#define _nsRenderingContextOS2_h
|
||||||
|
|
||||||
#include "nsIRenderingContext.h"
|
#include "nsIRenderingContext.h"
|
||||||
|
#include "nsFont.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsTransform2D.h"
|
#include "nsTransform2D.h"
|
||||||
#include "nscoord.h"
|
#include "nscoord.h"
|
||||||
@ -38,11 +39,9 @@
|
|||||||
|
|
||||||
class nsIDeviceContext;
|
class nsIDeviceContext;
|
||||||
class nsIFontMetrics;
|
class nsIFontMetrics;
|
||||||
class nsIPaletteOS2;
|
|
||||||
class nsString;
|
class nsString;
|
||||||
class nsIWidget;
|
class nsIWidget;
|
||||||
class nsPoint;
|
class nsPoint;
|
||||||
class nsFont;
|
|
||||||
class nsRect;
|
class nsRect;
|
||||||
|
|
||||||
class GraphicsState;
|
class GraphicsState;
|
||||||
@ -238,7 +237,6 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsIDeviceContext *mContext; // device context
|
nsIDeviceContext *mContext; // device context
|
||||||
nsIPaletteOS2 *mPalette; // palette from the dc
|
|
||||||
nsDrawingSurfaceOS2 *mSurface; // draw things here
|
nsDrawingSurfaceOS2 *mSurface; // draw things here
|
||||||
nsDrawingSurfaceOS2 *mFrontSurface; // if offscreen, this is onscreen
|
nsDrawingSurfaceOS2 *mFrontSurface; // if offscreen, this is onscreen
|
||||||
nscolor mColor; // current colour
|
nscolor mColor; // current colour
|
||||||
@ -249,9 +247,12 @@ protected:
|
|||||||
nsIFontMetrics *mFontMetrics; // current font
|
nsIFontMetrics *mFontMetrics; // current font
|
||||||
nsIFontMetrics *mCurrFontMetrics; // currently selected font
|
nsIFontMetrics *mCurrFontMetrics; // currently selected font
|
||||||
nscolor mCurrDrawingColor;// currently selected drawing color
|
nscolor mCurrDrawingColor;// currently selected drawing color
|
||||||
|
PRUint8 *mGammaTable;
|
||||||
nscolor mCurrTextColor; // currently selected text color
|
nscolor mCurrTextColor; // currently selected text color
|
||||||
nsLineStyle mCurrLineStyle; // currently selected line style
|
nsLineStyle mCurrLineStyle; // currently selected line style
|
||||||
HDC mDC;
|
HDC mDC;
|
||||||
|
nsIWidget *mDCOwner;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void nsRenderingContextOS2::GetTargetHeight( PRUint32 &ht)
|
inline void nsRenderingContextOS2::GetTargetHeight( PRUint32 &ht)
|
||||||
|
Loading…
Reference in New Issue
Block a user