Compare commits

..

2 Commits

Author SHA1 Message Date
heikki%netscape.com
a637f81f7f new project started
git-svn-id: svn://10.0.0.236/branches/mozilla@91184 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-03 22:13:38 +00:00
(no author)
6cfadae5d1 This commit was manufactured by cvs2svn to create branch 'mozilla'.
git-svn-id: svn://10.0.0.236/branches/mozilla@8534 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-26 18:36:10 +00:00
445 changed files with 76 additions and 188749 deletions

View File

@@ -1,36 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public idl src
ifdef ENABLE_TESTS
DIRS += tests
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,11 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:dist:widget directory
#
nsIFontEnumerator.idl
nsIFontList.idl
nsIScriptableRegion.idl
nsIScreen.idl
nsIScreenManager.idl
nsIPrintOptions.idl
nsIPrintSettings.idl

View File

@@ -1,44 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx
XPIDL_MODULE = gfx
XPIDLSRCS = \
nsIFontEnumerator.idl \
nsIFontList.idl \
nsIScriptableRegion.idl \
nsIGraphics.idl \
nsIScreen.idl \
nsIScreenManager.idl \
nsIPrintOptions.idl \
nsIPrintSettings.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,89 +0,0 @@
#!/usr/local/bin/perl
require "find.pl";
$uuid = 0x6f7652e0;
$format = "{ 0x%x, 0xee43, 0x11d1, \\\
{ 0x9c, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }";
$pattern = "--- IID GOES HERE ---";
$mydir = cwd();
sub replaceText {
local ($oldname) = $_;
local ($newname) = $_;
local ($found) = 0;
local ($tempname) = $oldname.'.orig';
local ($replacement);
if (-T $oldname && -s $oldname) {
open(FILE, "<$oldname")
|| die "Unable to open $oldname\n";
while (<FILE>) {
if (/$pattern/) {
$found = 1;
last;
}
}
close(FILE);
if ($found) {
print "Setting IID for file: ", $oldname, "\n";
rename($oldname, $tempname)
|| die "Unable to rename $oldname as $tempname";
open(REPLACEFILE, ">$newname")
|| die "Unable to open $newname for writing\n";
open(SEARCHFILE, "<$tempname")
|| die "Unable to open $tempname\n";
while (<SEARCHFILE>) {
if (/$pattern/) {
$replacement = sprintf($format, $uuid++);
s/$pattern/$replacement /g;
}
print REPLACEFILE;
}
close(SEARCHFILE);
close(REPLACEFILE);
if (-z $newname) {
die "$newname has zero size\n."
."Restore manually from $tempname\n";
} else {
unlink($tempname);
}
warn "$name: Renaming as $newname\n" if $newname ne $oldname;
$_ = $oldname;
return;
}
}
if ($newname ne $oldname) {
warn "$name: Renaming as $newname\n";
rename($oldname, $newname) || warn "Unable to rename $oldname\n";
}
$_ = $oldname;
}
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# Traverse desired filesystems
$dont_use_nlink = 1;
if (!$ARGV[0]) {
&find('.');
}
else {
foreach $file (@ARGV) {
chdir $mydir
&find($file);
}
}
exit;
sub wanted {
/^nsIDOM.*\.h$/ &&
&replaceText($name);
}

View File

@@ -1,42 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..
DEFINES=-D_IMPL_NS_UI
MODULE=gfx
XPIDLSRCS = \
.\nsIFontEnumerator.idl \
.\nsIFontList.idl \
.\nsIScriptableRegion.idl \
.\nsIScreen.idl \
.\nsIScreenManager.idl \
.\nsIPrintOptions.idl \
.\nsIPrintSettings.idl \
$(NULL)
EXPORTS= \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,61 +0,0 @@
/* -*- Mode: IDL; 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" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
* Erik van der Poel
*/
#include "nsISupports.idl"
[scriptable, uuid(a6cf9114-15b3-11d2-932e-00805f8add32)]
interface nsIFontEnumerator : nsISupports
{
/**
* Return a sorted array of the names of all installed fonts.
*
* @param aCount returns number of names returned
* @param aResult returns array of names
* @return void
*/
void EnumerateAllFonts(out PRUint32 aCount,
[retval, array, size_is(aCount)] out wstring aResult);
/**
* Return a sorted array of names of fonts that support the given language
* group and are suitable for use as the given CSS generic font.
*
* @param aLangGroup language group
* @param aGeneric CSS generic font
* @param aCount returns number of names returned
* @param aResult returns array of names
* @return void
*/
void EnumerateFonts(in string aLangGroup, in string aGeneric,
out PRUint32 aCount, [retval, array, size_is(aCount)] out wstring aResult);
/*
@param aLangGroup language group
@return bool do we have a font for this language group
*/
void HaveFontFor(in string aLangGroup, [retval] out boolean aResult);
/*
* update the global font list
* return true if font list is changed
*/
boolean updateFontList();
};

View File

@@ -1,80 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Stell <bstell@netscape.com>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsISimpleEnumerator;
/**
* The nsIFontList interface provides an application the
* necessary information so that the user can select the font to use
* as the default style sheet. This is used if the style sheet is
* missing or does not specify a font.
* <P>Font lists are specified per language group.
*
*/
[scriptable, uuid(702909c6-1dd2-11b2-b833-8a740f643539)]
interface nsIFontList : nsISupports
{
/**
* Get the list of available fonts for a language group
* and for use as the given CSS generic font.
*
* @param aLangGroup limits the fonts to fonts in a language
* group; eg: x-western (American/Western European),
* ar (Arabic), el (Greek), he (Hebrew), ja (Japanese),
* ko (Korean), th (Thai), tr (Turkish),
* x-baltic (Baltic), x-central-euro (Eastern European),
* x-cyrillic (Russian), zh-CN (China), zh-TW (Taiwan)
*
* @param aFontType limits the fonts to the fonts with this CSS
* generic font type; eg: serif, sans-serif, cursive,
* fantasy, monospace.
*
* @return a simple enumerator of the available fonts for a
* language group / generic type. These strings are
* the text supplied by the operating system's font
* system.
*/
nsISimpleEnumerator availableFonts(in wstring aLangGroup,
in wstring aFontType);
};

View File

@@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Patrick C. Beard <beard@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
typedef unsigned long nscolor;
typedef long nscoord;
/**
* Simplified graphics interface for JS rendering.
*/
[scriptable, uuid(812EAE54-1DD2-11B2-B17B-D0ACC700F975)]
interface nsIGraphics : nsISupports
{
/**
* The color used to paint with.
*/
attribute nscolor color;
/**
* Clipping.
*/
void clipRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
/**
* Primitives.
*/
void drawLine(in nscoord x1, in nscoord y1, in nscoord x2, in nscoord y2);
void drawRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
void fillRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
void invertRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
void drawEllipse(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
void fillEllipse(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
void invertEllipse(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
void drawArc(in nscoord x, in nscoord y, in nscoord width, in nscoord height, in float startAngle, in float endAngle);
void fillArc(in nscoord x, in nscoord y, in nscoord width, in nscoord height, in float startAngle, in float endAngle);
void invertArc(in nscoord x, in nscoord y, in nscoord width, in nscoord height, in float startAngle, in float endAngle);
void drawPolygon(in unsigned long count, [array, size_is(count)] in long points);
void fillPolygon(in unsigned long count, [array, size_is(count)] in long points);
void invertPolygon(in unsigned long count, [array, size_is(count)] in long points);
void drawString(in wstring text, in nscoord x, in nscoord y);
void setFont(in wstring name, in nscoord size);
/**
* Stack of graphics states.
*/
void gsave();
void grestore();
};

View File

@@ -1,304 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Don Cone <dcone@netscape.com>
* Jessica Blanco <jblanco@us.ibm.com>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIPrintSettings.idl"
%{ C++
#include "nsFont.h"
%}
interface nsISimpleEnumerator;
/**
* Native types
*/
[ref] native nsNativeFontRef(nsFont);
[ref] native nsNativeStringRef(nsString);
/**
* Simplified graphics interface for JS rendering.
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(CAE87E20-479E-11d4-A856-00105A183419)]
interface nsIPrintOptions : nsISupports
{
/* Print Option Flags for Bit Field*/
const long kOptPrintOddPages = 0x00000001;
const long kOptPrintEvenPages = 0x00000002;
const long kPrintOptionsEnableSelectionRB = 0x00000004;
/* Print Range Enums */
const long kRangeAllPages = 0;
const long kRangeSpecifiedPageRange = 1;
const long kRangeSelection = 2;
const long kRangeFocusFrame = 3;
/* Justification Enums */
const long kJustLeft = 0;
const long kJustCenter = 1;
const long kJustRight = 2;
/**
* Page Size Constants (NOTE: These have been deprecated!);
*/
const short kLetterPaperSize = 0;
const short kLegalPaperSize = 1;
const short kExecutivePaperSize = 2;
const short kA4PaperSize = 3;
const short kA3PaperSize = 4;
/**
* FrameSet Default Type Constants
*/
const short kUseInternalDefault = 0;
const short kUseSettingWhenPossible = 1;
/**
* Page Size Type Constants
*/
const short kPaperSizeNativeData = 0;
const short kPaperSizeDefined = 1;
/**
* Page Size Unit Constants
*/
const short kPaperSizeInches = 0;
const short kPaperSizeMillimeters = 1;
/**
* Orientation Constants
*/
const short kPortraitOrientation = 0;
const short kLandscapeOrientation = 1;
/**
* Print Frame Constants
*/
const short kNoFrames = 0;
const short kFramesAsIs = 1;
const short kSelectedFrame = 2;
const short kEachFrameSep = 3;
/**
* How to Enable Frame Set Printing Constants
*/
const short kFrameEnableNone = 0;
const short kFrameEnableAll = 1;
const short kFrameEnableAsIsAndEach = 2;
/**
* Show Native Print Options dialog, this may not be supported on all platforms
*/
void ShowNativeDialog();
/**
* Set PrintOptions
*/
void SetPrintOptions(in PRInt32 aType, in PRBool aTurnOnOff);
/**
* Get PrintOptions
*/
PRBool GetPrintOptions(in PRInt32 aType);
/**
* Set PrintOptions Bit field
*/
PRInt32 GetPrintOptionsBits();
/**
* Read Prefs
*/
void ReadPrefs();
/**
* Write Prefs
*/
void WritePrefs();
/**
* Creates a new PrintSettnigs Object
* and initializes it from prefs
*/
nsIPrintSettings CreatePrintSettings();
/**
* Initialize the values in the PrintSettings from Prefs
*/
void InitPrintSettingsFromPrefs(in nsIPrintSettings aPO);
/**
* Data Members
*/
attribute long startPageRange;
attribute long endPageRange;
attribute double marginTop; /* these are in inches */
attribute double marginLeft;
attribute double marginBottom;
attribute double marginRight;
attribute double scaling; /* values 0.0 - 1.0 */
attribute boolean printBGColors; /* Print Background Colors */
attribute boolean printBGImages; /* Print Background Images */
attribute short printRange;
attribute wstring title;
attribute wstring docURL;
attribute wstring headerStrLeft;
attribute wstring headerStrCenter;
attribute wstring headerStrRight;
attribute wstring footerStrLeft;
attribute wstring footerStrCenter;
attribute wstring footerStrRight;
attribute short howToEnableFrameUI;
attribute boolean isCancelled;
attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not*/
attribute short printFrameType;
attribute boolean printSilent; /* print without putting up the dialog */
attribute nsIPrintSettings printSettingsValues; /* used copy the values to/from the settings obj*/
attribute nsIPrintSettings printSettings; /* used to set and get the current object */
/* Additional XP Related */
attribute short paperSizeType; /* use native data or is defined here */
attribute short paperData; /* native data value */
attribute double paperWidth; /* width of the paper in inches or mm */
attribute double paperHeight; /* height of the paper in inches or mm */
attribute short paperSizeUnit; /* paper is in inches or mm */
attribute long paperSize; /* This has been deprecated */
attribute boolean printReversed;
attribute boolean printInColor; /* a false means grayscale */
attribute long orientation; /* see orientation consts */
attribute wstring printCommand;
attribute long numCopies;
attribute wstring printerName;
attribute boolean printToFile;
attribute wstring toFileName;
attribute long printPageDelay; /* in milliseconds */
/* No Script Methods */
[noscript] void SetFontNamePointSize(in nsNativeStringRef aName, in PRInt32 aPointSize);
[noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin);
/* Purposely made this an "in" arg */
[noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin);
[noscript] void SetDefaultFont(in nsNativeFontRef aMargin);
/* Purposely made this an "in" arg */
[noscript] void GetDefaultFont(in nsNativeFontRef aMargin);
[noscript] void GetPageSizeInTwips(out long aWidth, out long aHeight);
/**
* available Printers
*/
nsISimpleEnumerator availablePrinters ();
/**
* Indicates whether the list of printers contains the extended
* information. i.e. That there are "pairs" of values returned. Where the second
* value is either "FILE", "PRINTER", "BOTH"
*
*/
readonly attribute boolean isExtended;
/**
* display Printer Job Properties dialog
*/
void displayJobProperties (in wstring aPrinter, in nsIPrintSettings aPrintSettings, out boolean aDisplayed);
/**
* Native data constants
*/
const short kNativeDataPrintRecord = 0;
[noscript] voidPtr GetNativeData(in short aDataType);
};
[scriptable, uuid(a6cf9128-15b3-11d2-932e-00805f8add32)]
interface nsIPrinterEnumerator : nsISupports
{
/**
* Returns an array of the names of all installed printers.
*
* @param aCount returns number of printers returned
* @param aResult returns array of names
* @return void
*/
void enumeratePrinters(out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult);
/**
* Returns an array of "pairs" of strings
* The first string in the pair is the printer name
* the second string in the pair is can be "FILE", "PRINTER", or "BOTH"
* which indicates whether the printer driver associated with this printer
* ALWAYS "spools" to a file or to a printer.
*
* If this type of information is not available, it should return zero items
*
* Note: On some platforms any given driveris able to spool to either
*
* @param aCount returns number of printers AND info strings returned
* i.e If there are 5 printers define the
* "count" returned will be 10
* @param aResult returns array of names
* @return void
*/
void enumeratePrintersExtended(out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult);
/* takes printer selected and will display job properties dlg for that printer
* returns true if dialog displays
*/
void displayPropertiesDlg(in wstring aPrinter, in nsIPrintSettings aPrintSettings);
};

View File

@@ -1,196 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Don Cone <dcone@netscape.com>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
%{ C++
#include "nsMargin.h"
#include "nsFont.h"
%}
/**
* Native types
*/
[ref] native nsNativeMarginRef(nsMargin);
/**
* Simplified graphics interface for JS rendering.
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(83427530-F790-11d4-A869-00105A183419)]
interface nsIPrintSettings : nsISupports
{
/* Print Option Flags for Bit Field*/
const long kPrintOddPages = 0x00000001;
const long kPrintEvenPages = 0x00000002;
const long kEnableSelectionRB = 0x00000004;
/* Print Range Enums */
const long kRangeAllPages = 0;
const long kRangeSpecifiedPageRange = 1;
const long kRangeSelection = 2;
const long kRangeFocusFrame = 3;
/* Justification Enums */
const long kJustLeft = 0;
const long kJustCenter = 1;
const long kJustRight = 2;
/**
* FrameSet Default Type Constants
*/
const short kUseInternalDefault = 0;
const short kUseSettingWhenPossible = 1;
/**
* Page Size Type Constants
*/
const short kPaperSizeNativeData = 0;
const short kPaperSizeDefined = 1;
/**
* Page Size Unit Constants
*/
const short kPaperSizeInches = 0;
const short kPaperSizeMillimeters = 1;
/**
* Orientation Constants
*/
const short kPortraitOrientation = 0;
const short kLandscapeOrientation = 1;
/**
* Print Frame Constants
*/
const short kNoFrames = 0;
const short kFramesAsIs = 1;
const short kSelectedFrame = 2;
const short kEachFrameSep = 3;
/**
* How to Enable Frame Set Printing Constants
*/
const short kFrameEnableNone = 0;
const short kFrameEnableAll = 1;
const short kFrameEnableAsIsAndEach = 2;
/**
* Set PrintOptions
*/
void SetPrintOptions(in PRInt32 aType, in PRBool aTurnOnOff);
/**
* Get PrintOptions
*/
PRBool GetPrintOptions(in PRInt32 aType);
/**
* Set PrintOptions Bit field
*/
PRInt32 GetPrintOptionsBits();
/**
* Returns W/H in Twips from Paper Size H/W
*/
void GetPageSizeInTwips(out long aWidth, out long aHeight);
/**
* Data Members
*/
attribute long startPageRange;
attribute long endPageRange;
attribute double marginTop; /* these are in inches */
attribute double marginLeft;
attribute double marginBottom;
attribute double marginRight;
attribute double scaling; /* values 0.0 - 1.0 */
attribute boolean printBGColors; /* Print Background Colors */
attribute boolean printBGImages; /* Print Background Images */
attribute short printRange;
attribute wstring title;
attribute wstring docURL;
attribute wstring headerStrLeft;
attribute wstring headerStrCenter;
attribute wstring headerStrRight;
attribute wstring footerStrLeft;
attribute wstring footerStrCenter;
attribute wstring footerStrRight;
attribute short howToEnableFrameUI; /* indicates how to enable the frameset UI */
attribute boolean isCancelled; /* indicates whether the print job has been cancelled */
attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not */
attribute short printFrameType;
attribute boolean printSilent; /* print without putting up the dialog */
/* Additional XP Related */
attribute short paperSizeType; /* use native data or is defined here */
attribute short paperData; /* native data value */
attribute double paperWidth; /* width of the paper in inches or mm */
attribute double paperHeight; /* height of the paper in inches or mm */
attribute short paperSizeUnit; /* paper is in inches or mm */
attribute boolean printReversed;
attribute boolean printInColor; /* a false means grayscale */
attribute long paperSize; /* see page size consts */
attribute long orientation; /* see orientation consts */
attribute wstring printCommand;
attribute long numCopies;
attribute wstring printerName;
attribute boolean printToFile;
attribute wstring toFileName;
attribute long printPageDelay; /* in milliseconds */
/* C++ Helper Functions */
[noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin);
/* Purposely made this an "in" arg */
[noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin);
};

View File

@@ -1,38 +0,0 @@
/* -*- Mode: IDL; 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" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 2000 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
[scriptable, uuid(f728830e-1dd1-11b2-9598-fb9f414f2465)]
interface nsIScreen : nsISupports
{
void GetRect ( out long left, out long top, out long width, out long height );
void GetAvailRect ( out long left, out long top, out long width, out long height );
readonly attribute long pixelDepth;
readonly attribute long colorDepth;
};
%{ C++
%}

View File

@@ -1,49 +0,0 @@
/* -*- Mode: IDL; 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" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 2000 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsIScreen.idl"
[scriptable, uuid(662e7b78-1dd2-11b2-a3d3-fc1e5f5fb9d4)]
interface nsIScreenManager : nsISupports
{
//
// 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.
//
nsIScreen screenForRect ( in long left, in long top, in long width, in long height ) ;
// The screen with the menubar/taskbar. This shouldn't be needed very
// often.
readonly attribute nsIScreen primaryScreen;
// Holds the number of screens that are available
readonly attribute unsigned long numberOfScreens;
};
%{ C++
%}

View File

@@ -1,190 +0,0 @@
/* -*- Mode: IDL; 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" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
* Communications Corp. All Rights Reserved.
*
* Contributor(s):
* Mike Pinkerton
*/
#include "nsISupports.idl"
%{C++
class nsIRegion;
%}
[ptr] native nsIRegion(nsIRegion);
[scriptable, uuid(82d8f400-5bde-11d3-b033-b27a62766bbc)]
interface nsIScriptableRegion : nsISupports
{
void init ( ) ;
/**
* copy operator equivalent that takes another region
*
* @param region to copy
* @return void
*
**/
void setToRegion ( in nsIScriptableRegion aRegion );
/**
* copy operator equivalent that takes a rect
*
* @param aX xoffset of rect to set region to
* @param aY yoffset of rect to set region to
* @param aWidth width of rect to set region to
* @param aHeight height of rect to set region to
* @return void
*
**/
void setToRect ( in long aX, in long aY, in long aWidth, in long aHeight );
/**
* destructively intersect another region with this one
*
* @param region to intersect
* @return void
*
**/
void intersectRegion ( in nsIScriptableRegion aRegion ) ;
/**
* destructively intersect a rect with this region
*
* @param aX xoffset of rect to intersect with region
* @param aY yoffset of rect to intersect with region
* @param aWidth width of rect to intersect with region
* @param aHeight height of rect to intersect with region
* @return void
*
**/
void intersectRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
/**
* destructively union another region with this one
*
* @param region to union
* @return void
*
**/
void unionRegion ( in nsIScriptableRegion aRegion ) ;
/**
* destructively union a rect with this region
*
* @param aX xoffset of rect to union with region
* @param aY yoffset of rect to union with region
* @param aWidth width of rect to union with region
* @param aHeight height of rect to union with region
* @return void
*
**/
void unionRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
/**
* destructively subtract another region with this one
*
* @param region to subtract
* @return void
*
**/
void subtractRegion ( in nsIScriptableRegion aRegion ) ;
/**
* destructively subtract a rect from this region
*
* @param aX xoffset of rect to subtract with region
* @param aY yoffset of rect to subtract with region
* @param aWidth width of rect to subtract with region
* @param aHeight height of rect to subtract with region
* @return void
*
**/
void subtractRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
/**
* is this region empty? i.e. does it contain any pixels
*
* @param none
* @return returns whether the region is empty
*
**/
boolean isEmpty ( ) ;
/**
* == operator equivalent i.e. do the regions contain exactly
* the same pixels
*
* @param region to compare
* @return whether the regions are identical
*
**/
boolean isEqualRegion ( in nsIScriptableRegion aRegion ) ;
/**
* returns the bounding box of the region i.e. the smallest
* rectangle that completely contains the region.
*
* @param aX out parameter for xoffset of bounding rect for region
* @param aY out parameter for yoffset of bounding rect for region
* @param aWidth out parameter for width of bounding rect for region
* @param aHeight out parameter for height of bounding rect for region
* @return void
*
**/
void getBoundingBox ( out long aX, out long aY, out long aWidth, out long aHeight ) ;
/**
* offsets the region in x and y
*
* @param xoffset pixel offset in x
* @param yoffset pixel offset in y
* @return void
*
**/
void offset ( in long aXOffset, in long aYOffset ) ;
/**
* does the region intersect the rectangle?
*
* @param rect to check for containment
* @return true if the region intersects the rect
*
**/
boolean containsRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
[noscript] readonly attribute nsIRegion region;
};
%{ C++
%}

View File

@@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#if TARGET_CARBON
// we can't use the carbon printing session APIs
#define PM_USE_SESSION_APIS 0
#endif

View File

@@ -1,24 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "MacPrefix_debug.h"
#include "GFXComponentConfig.h"

View File

@@ -1,24 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "MacSharedPrefix.h"
#include "GFXComponentConfig.h"

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "GFXConfig.h"
#include "MacPrefix_debug.h"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..
DIRS= public src \
!if !defined(DISABLE_TESTS)
tests \
!endif
idl
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,30 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:dist:widget directory
#
nsColor.h
nsColorNames.h
nsColorNameList.h
nsCoord.h
nsFont.h
nsRect.h
nsPoint.h
nsSize.h
nsMargin.h
nsTransform2D.h
nsIRenderingContext.h
nsIFontMetrics.h
nsIDeviceContext.h
nsIImage.h
nsIBlender.h
nsGfxCIID.h
nsIRegion.h
nsDeviceContext.h
nsRenderingContextImpl.h
nsIDeviceContextSpec.h
nsIDeviceContextSpecFactory.h
nsIDrawingSurface.h
nsRepeater.h
nsThemeConstants.h
nsITheme.h

View File

@@ -1,66 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx
EXPORTS = \
imgScaler.h \
nsColor.h \
nsColorNames.h \
nsColorNameList.h \
nsCompressedCharMap.h \
nsCoord.h \
nsFont.h \
nsRect.h \
nsRepeater.h \
nsPoint.h \
nsSize.h \
nsMargin.h \
nsTransform2D.h \
nsIRenderingContext.h \
nsRenderingContextImpl.h \
nsIFontMetrics.h \
nsIDeviceContext.h \
nsIImage.h \
nsIBlender.h \
nsGfxCIID.h \
nsIRegion.h \
nsDeviceContext.h \
nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h \
nsIDrawingSurface.h \
nsITheme.h \
nsThemeConstants.h \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),mac)
EXPORTS += nsIPrintingContext.h
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,27 +0,0 @@
/*
* 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 Tomas Mšller
* Portions created by Tomas Mšller are
* Copyright (C) 2001 Tomas Mšller. Rights Reserved.
*
* Contributor(s):
* Tomas Mšller
* Tim Rowley <tor@cs.brown.edu>
*/
void RectStretch(long xs1,long ys1,long xs2,long ys2,
long xd1,long yd1,long xd2,long yd2,
unsigned char *aSrcImage, unsigned aSrcStride,
unsigned char *aDstImage, unsigned aDstStride,
unsigned aDepth);

View File

@@ -1,56 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..
EXPORTS = \
nsColor.h \
nsColorNames.h \
nsColorNameList.h \
nsCoord.h \
nsFont.h \
nsRect.h \
nsPoint.h \
nsSize.h \
nsMargin.h \
nsTransform2D.h \
nsIRenderingContext.h \
nsRenderingContextImpl.h \
nsIFontMetrics.h \
nsIDeviceContext.h \
nsIImage.h \
nsIBlender.h \
nsGfxCIID.h \
nsIRegion.h \
nsDeviceContext.h \
nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h \
nsIDrawingSurface.h \
nsCompressedCharMap.h \
nsThemeConstants.h \
nsITheme.h \
$(NULL)
MODULE=gfx
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,119 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsColor_h___
#define nsColor_h___
#include "nscore.h"
class nsString;
class nsAString;
// A color is a 32 bit unsigned integer with four components: R, G, B
// and A.
typedef PRUint32 nscolor;
// Make a color out of r,g,b values. This assumes that the r,g,b values are
// properly constrained to 0-255. This also assumes that a is 255.
#define NS_RGB(_r,_g,_b) \
((nscolor) ((255 << 24) | ((_b)<<16) | ((_g)<<8) | (_r)))
// Make a color out of r,g,b,a values. This assumes that the r,g,b,a
// values are properly constrained to 0-255.
#define NS_RGBA(_r,_g,_b,_a) \
((nscolor) (((_a) << 24) | ((_b)<<16) | ((_g)<<8) | (_r)))
// Extract color components from nscolor
#define NS_GET_R(_rgba) ((PRUint8) ((_rgba) & 0xff))
#define NS_GET_G(_rgba) ((PRUint8) (((_rgba) >> 8) & 0xff))
#define NS_GET_B(_rgba) ((PRUint8) (((_rgba) >> 16) & 0xff))
#define NS_GET_A(_rgba) ((PRUint8) (((_rgba) >> 24) & 0xff))
// Fast approximate division by 255. It has the property that
// for all 0 <= n <= 255*255, FAST_DIVIDE_BY_255(n) == n/255.
// But it only uses two adds and two shifts instead of an
// integer division (which is expensive on many processors).
//
// equivalent to target=v/255
#define FAST_DIVIDE_BY_255(target,v) \
PR_BEGIN_MACRO \
unsigned tmp_ = v; \
target = ((tmp_ << 8) + tmp_ + 255) >> 16; \
PR_END_MACRO
// Blending macro
//
// equivalent to target=(bg*(255-alpha)+fg*alpha)/255
#define MOZ_BLEND(target, bg, fg, alpha) \
FAST_DIVIDE_BY_255(target, (bg)*(255-(alpha)) + (fg)*(alpha))
// Translate a hex string to a color. Return true if it parses ok,
// otherwise return false.
// This accepts only 3, 6 or 9 digits
extern "C" NS_GFX_(PRBool) NS_HexToRGB(const nsString& aBuf, nscolor* aResult);
// Translate a hex string to a color. Return true if it parses ok,
// otherwise return false.
// This version accepts 1 to 9 digits (missing digits are 0)
extern "C" NS_GFX_(PRBool) NS_LooseHexToRGB(const nsString& aBuf, nscolor* aResult);
// Translate a color name to a color. Return true if it parses ok,
// otherwise return false.
extern "C" NS_GFX_(PRBool) NS_ColorNameToRGB(const nsAString& aBuf, nscolor* aResult);
// Weird color computing code stolen from winfe which was stolen
// from the xfe which was written originally by Eric Bina. So there.
extern "C" NS_GFX_(void) NS_Get3DColors(nscolor aResult[2], nscolor aColor);
// To determin colors based on the background brightness
extern "C" NS_GFX_(void) NS_GetSpecial3DColors(nscolor aResult[2],
nscolor aBackgroundColor,
nscolor aBorderColor);
// Special method to brighten a Color and have it shift to white when
// fully saturated.
extern "C" NS_GFX_(nscolor) NS_BrightenColor(nscolor inColor);
// Special method to darken a Color and have it shift to black when
// darkest component underflows
extern "C" NS_GFX_(nscolor) NS_DarkenColor(nscolor inColor);
// Determins brightness for a specific color
extern "C" NS_GFX_(int) NS_GetBrightness(PRUint8 aRed, PRUint8 aGreen, PRUint8 aBlue);
#endif /* nsColor_h___ */

View File

@@ -1,212 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/******
This file contains the list of all named colors
See nsCSSColorNames.h for access to the enum values for colors
It is designed to be used as inline input to nsCSSColorNames.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro GFX_COLOR which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to GFX_COLOR is both the enum identifier of the color
and the string value
The second argument is the sRGBA value for the named color
'name' entries *must* use only lowercase characters.
** Break these invarient and bad things will happen. **
******/
GFX_COLOR(aliceblue, NS_RGB(240, 248, 255))
GFX_COLOR(antiquewhite, NS_RGB(250, 235, 215))
GFX_COLOR(aqua, NS_RGB( 0, 255, 255))
GFX_COLOR(aquamarine, NS_RGB(127, 255, 212))
GFX_COLOR(azure, NS_RGB(240, 255, 255))
GFX_COLOR(beige, NS_RGB(245, 245, 220))
GFX_COLOR(bisque, NS_RGB(255, 228, 196))
GFX_COLOR(black, NS_RGB( 0, 0, 0))
GFX_COLOR(blanchedalmond, NS_RGB(255, 235, 205))
GFX_COLOR(blue, NS_RGB( 0, 0, 255))
GFX_COLOR(blueviolet, NS_RGB(138, 43, 226))
GFX_COLOR(brown, NS_RGB(165, 42, 42))
GFX_COLOR(burlywood, NS_RGB(222, 184, 135))
GFX_COLOR(cadetblue, NS_RGB( 95, 158, 160))
GFX_COLOR(chartreuse, NS_RGB(127, 255, 0))
GFX_COLOR(chocolate, NS_RGB(210, 105, 30))
GFX_COLOR(coral, NS_RGB(255, 127, 80))
GFX_COLOR(cornflowerblue, NS_RGB(100, 149, 237))
GFX_COLOR(cornsilk, NS_RGB(255, 248, 220))
GFX_COLOR(crimson, NS_RGB(220, 20, 60))
GFX_COLOR(cyan, NS_RGB( 0, 255, 255))
GFX_COLOR(darkblue, NS_RGB( 0, 0, 139))
GFX_COLOR(darkcyan, NS_RGB( 0, 139, 139))
GFX_COLOR(darkgoldenrod, NS_RGB(184, 134, 11))
GFX_COLOR(darkgray, NS_RGB(169, 169, 169))
GFX_COLOR(darkgreen, NS_RGB( 0, 100, 0))
GFX_COLOR(darkgrey, NS_RGB(169, 169, 169))
GFX_COLOR(darkkhaki, NS_RGB(189, 183, 107))
GFX_COLOR(darkmagenta, NS_RGB(139, 0, 139))
GFX_COLOR(darkolivegreen, NS_RGB( 85, 107, 47))
GFX_COLOR(darkorange, NS_RGB(255, 140, 0))
GFX_COLOR(darkorchid, NS_RGB(153, 50, 204))
GFX_COLOR(darkred, NS_RGB(139, 0, 0))
GFX_COLOR(darksalmon, NS_RGB(233, 150, 122))
GFX_COLOR(darkseagreen, NS_RGB(143, 188, 143))
GFX_COLOR(darkslateblue, NS_RGB( 72, 61, 139))
GFX_COLOR(darkslategray, NS_RGB( 47, 79, 79))
GFX_COLOR(darkslategrey, NS_RGB( 47, 79, 79))
GFX_COLOR(darkturquoise, NS_RGB( 0, 206, 209))
GFX_COLOR(darkviolet, NS_RGB(148, 0, 211))
GFX_COLOR(deeppink, NS_RGB(255, 20, 147))
GFX_COLOR(deepskyblue, NS_RGB( 0, 191, 255))
GFX_COLOR(dimgray, NS_RGB(105, 105, 105))
GFX_COLOR(dimgrey, NS_RGB(105, 105, 105))
GFX_COLOR(dodgerblue, NS_RGB( 30, 144, 255))
GFX_COLOR(firebrick, NS_RGB(178, 34, 34))
GFX_COLOR(floralwhite, NS_RGB(255, 250, 240))
GFX_COLOR(forestgreen, NS_RGB( 34, 139, 34))
GFX_COLOR(fuchsia, NS_RGB(255, 0, 255))
GFX_COLOR(gainsboro, NS_RGB(220, 220, 220))
GFX_COLOR(ghostwhite, NS_RGB(248, 248, 255))
GFX_COLOR(gold, NS_RGB(255, 215, 0))
GFX_COLOR(goldenrod, NS_RGB(218, 165, 32))
GFX_COLOR(gray, NS_RGB(128, 128, 128))
GFX_COLOR(grey, NS_RGB(128, 128, 128))
GFX_COLOR(green, NS_RGB( 0, 128, 0))
GFX_COLOR(greenyellow, NS_RGB(173, 255, 47))
GFX_COLOR(honeydew, NS_RGB(240, 255, 240))
GFX_COLOR(hotpink, NS_RGB(255, 105, 180))
GFX_COLOR(indianred, NS_RGB(205, 92, 92))
GFX_COLOR(indigo, NS_RGB( 75, 0, 130))
GFX_COLOR(ivory, NS_RGB(255, 255, 240))
GFX_COLOR(khaki, NS_RGB(240, 230, 140))
GFX_COLOR(lavender, NS_RGB(230, 230, 250))
GFX_COLOR(lavenderblush, NS_RGB(255, 240, 245))
GFX_COLOR(lawngreen, NS_RGB(124, 252, 0))
GFX_COLOR(lemonchiffon, NS_RGB(255, 250, 205))
GFX_COLOR(lightblue, NS_RGB(173, 216, 230))
GFX_COLOR(lightcoral, NS_RGB(240, 128, 128))
GFX_COLOR(lightcyan, NS_RGB(224, 255, 255))
GFX_COLOR(lightgoldenrodyellow, NS_RGB(250, 250, 210))
GFX_COLOR(lightgray, NS_RGB(211, 211, 211))
GFX_COLOR(lightgreen, NS_RGB(144, 238, 144))
GFX_COLOR(lightgrey, NS_RGB(211, 211, 211))
GFX_COLOR(lightpink, NS_RGB(255, 182, 193))
GFX_COLOR(lightsalmon, NS_RGB(255, 160, 122))
GFX_COLOR(lightseagreen, NS_RGB( 32, 178, 170))
GFX_COLOR(lightskyblue, NS_RGB(135, 206, 250))
GFX_COLOR(lightslategray, NS_RGB(119, 136, 153))
GFX_COLOR(lightslategrey, NS_RGB(119, 136, 153))
GFX_COLOR(lightsteelblue, NS_RGB(176, 196, 222))
GFX_COLOR(lightyellow, NS_RGB(255, 255, 224))
GFX_COLOR(lime, NS_RGB( 0, 255, 0))
GFX_COLOR(limegreen, NS_RGB( 50, 205, 50))
GFX_COLOR(linen, NS_RGB(250, 240, 230))
GFX_COLOR(magenta, NS_RGB(255, 0, 255))
GFX_COLOR(maroon, NS_RGB(128, 0, 0))
GFX_COLOR(mediumaquamarine, NS_RGB(102, 205, 170))
GFX_COLOR(mediumblue, NS_RGB( 0, 0, 205))
GFX_COLOR(mediumorchid, NS_RGB(186, 85, 211))
GFX_COLOR(mediumpurple, NS_RGB(147, 112, 219))
GFX_COLOR(mediumseagreen, NS_RGB( 60, 179, 113))
GFX_COLOR(mediumslateblue, NS_RGB(123, 104, 238))
GFX_COLOR(mediumspringgreen, NS_RGB( 0, 250, 154))
GFX_COLOR(mediumturquoise, NS_RGB( 72, 209, 204))
GFX_COLOR(mediumvioletred, NS_RGB(199, 21, 133))
GFX_COLOR(midnightblue, NS_RGB( 25, 25, 112))
GFX_COLOR(mintcream, NS_RGB(245, 255, 250))
GFX_COLOR(mistyrose, NS_RGB(255, 228, 225))
GFX_COLOR(moccasin, NS_RGB(255, 228, 181))
GFX_COLOR(navajowhite, NS_RGB(255, 222, 173))
GFX_COLOR(navy, NS_RGB( 0, 0, 128))
GFX_COLOR(oldlace, NS_RGB(253, 245, 230))
GFX_COLOR(olive, NS_RGB(128, 128, 0))
GFX_COLOR(olivedrab, NS_RGB(107, 142, 35))
GFX_COLOR(orange, NS_RGB(255, 165, 0))
GFX_COLOR(orangered, NS_RGB(255, 69, 0))
GFX_COLOR(orchid, NS_RGB(218, 112, 214))
GFX_COLOR(palegoldenrod, NS_RGB(238, 232, 170))
GFX_COLOR(palegreen, NS_RGB(152, 251, 152))
GFX_COLOR(paleturquoise, NS_RGB(175, 238, 238))
GFX_COLOR(palevioletred, NS_RGB(219, 112, 147))
GFX_COLOR(papayawhip, NS_RGB(255, 239, 213))
GFX_COLOR(peachpuff, NS_RGB(255, 218, 185))
GFX_COLOR(peru, NS_RGB(205, 133, 63))
GFX_COLOR(pink, NS_RGB(255, 192, 203))
GFX_COLOR(plum, NS_RGB(221, 160, 221))
GFX_COLOR(powderblue, NS_RGB(176, 224, 230))
GFX_COLOR(purple, NS_RGB(128, 0, 128))
GFX_COLOR(red, NS_RGB(255, 0, 0))
GFX_COLOR(rosybrown, NS_RGB(188, 143, 143))
GFX_COLOR(royalblue, NS_RGB( 65, 105, 225))
GFX_COLOR(saddlebrown, NS_RGB(139, 69, 19))
GFX_COLOR(salmon, NS_RGB(250, 128, 114))
GFX_COLOR(sandybrown, NS_RGB(244, 164, 96))
GFX_COLOR(seagreen, NS_RGB( 46, 139, 87))
GFX_COLOR(seashell, NS_RGB(255, 245, 238))
GFX_COLOR(sienna, NS_RGB(160, 82, 45))
GFX_COLOR(silver, NS_RGB(192, 192, 192))
GFX_COLOR(skyblue, NS_RGB(135, 206, 235))
GFX_COLOR(slateblue, NS_RGB(106, 90, 205))
GFX_COLOR(slategray, NS_RGB(112, 128, 144))
GFX_COLOR(slategrey, NS_RGB(112, 128, 144))
GFX_COLOR(snow, NS_RGB(255, 250, 250))
GFX_COLOR(springgreen, NS_RGB( 0, 255, 127))
GFX_COLOR(steelblue, NS_RGB( 70, 130, 180))
GFX_COLOR(tan, NS_RGB(210, 180, 140))
GFX_COLOR(teal, NS_RGB( 0, 128, 128))
GFX_COLOR(thistle, NS_RGB(216, 191, 216))
GFX_COLOR(tomato, NS_RGB(255, 99, 71))
GFX_COLOR(turquoise, NS_RGB( 64, 224, 208))
GFX_COLOR(violet, NS_RGB(238, 130, 238))
GFX_COLOR(wheat, NS_RGB(245, 222, 179))
GFX_COLOR(white, NS_RGB(255, 255, 255))
GFX_COLOR(whitesmoke, NS_RGB(245, 245, 245))
GFX_COLOR(yellow, NS_RGB(255, 255, 0))
GFX_COLOR(yellowgreen, NS_RGB(154, 205, 50))

View File

@@ -1,80 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsColorNames_h___
#define nsColorNames_h___
#include "nsColor.h"
struct nsStr;
class nsAFlatCString;
class nsAString;
class nsACString;
/*
Declare the enum list using the magic of preprocessing
enum values are "eColorName_foo" (where foo is the color name)
To change the list of colors, see nsColorNameList.h
*/
#define GFX_COLOR(_name, _value) eColorName_##_name,
enum nsColorName {
eColorName_UNKNOWN = -1,
#include "nsColorNameList.h"
eColorName_COUNT
};
#undef GFX_COLOR
class NS_GFX nsColorNames {
public:
static void AddRefTable(void);
static void ReleaseTable(void);
// Given a color name, return the color enum value
// This only functions provided a valid ref on the table
static nsColorName LookupName(const nsAString& aName);
static nsColorName LookupName(const nsACString& aName);
static const nsAFlatCString& GetStringValue(nsColorName aColorName);
// Color id to rgb value table
static const nscolor kColors[];
};
#endif /* nsColorNames_h___ */

View File

@@ -1,348 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Stell <bstell@netscape.com>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSCOMPRESSEDCHARMAP_H
#define NSCOMPRESSEDCHARMAP_H
#include "prtypes.h"
#define ALU_SIZE PR_BITS_PER_LONG
//#define ALU_SIZE 16
//#define ALU_SIZE 32
//#define ALU_SIZE 64
#if (ALU_SIZE==32)
# define ALU_TYPE PRUint32
# define CCMAP_POW2(n) (1L<<(n))
# define CCMAP_BITS_PER_ALU_LOG2 5
#elif (ALU_SIZE==64)
# define ALU_TYPE PRUint64
# define CCMAP_POW2(n) (1LL<<(n))
# define CCMAP_BITS_PER_ALU_LOG2 6
#else
# define ALU_TYPE PRUint16
# define CCMAP_POW2(n) (1<<(n))
# define CCMAP_BITS_PER_ALU_LOG2 4
#endif
class nsICharRepresentable;
extern PRUint16* CreateEmptyCCMap();
extern PRUint16* MapToCCMap(PRUint32* aMap);
extern PRUint16* MapperToCCMap(nsICharRepresentable *aMapper);
extern void FreeCCMap(PRUint16* &aMap);
extern PRBool NextNonEmptyCCMapPage(PRUint16 *, PRUint16 *);
extern PRBool IsSameCCMap(PRUint16* ccmap1, PRUint16* ccmap2);
#ifdef DEBUG
void printCCMap(PRUint16* aCCMap);
#endif
// surrogate support extension
extern PRUint16*
MapToCCMapExt(PRUint32* aBmpPlaneMap, PRUint32** aOtherPlaneMaps, PRUint32 aOtherPlaneNum);
//
// nsCompressedCharMap
//
// A Compressed Char Map (CCMap) saves memory by folding all
// the empty portions of the map on top of each other.
//
// Building a Compressed Char Map (CCMap) is more complex than
// accessing it. We use the nsCompressedCharMap object to
// build the CCMap. Once nsCompressedCharMap has built the CCMap
// we get a copy of the CCMap and discard the nsCompressedCharMap
// object. The CCMap is an array of PRUint16 and is accessed by
// a macro.
//
// See "Character Map Compression" below for a discussion of
// what the array looks like.
//
// The maximum size a CCMap:
// (16 upper pointers) + (16 empty mid pointers) +
// (16 empty page) + (16*16 max mid pointers) +
// (256*16 max pages) = 4400 PRUint16
#define CCMAP_MAX_LEN (16+16+16+256+4096)
class nsCompressedCharMap {
public:
nsCompressedCharMap();
PRUint16* NewCCMap();
PRUint16* FillCCMap(PRUint16* aCCMap);
PRUint16 GetSize() {return mUsedLen;};
void SetChar(PRUint16);
void SetChars(PRUint16*);
void SetChars(PRUint16, ALU_TYPE*);
void SetChars(PRUint32*);
protected:
union {
PRUint16 mCCMap[CCMAP_MAX_LEN];
ALU_TYPE used_for_align; // do not use; only here to cause
// alignment
} u;
PRUint16 mUsedLen; // in PRUint16
PRUint16 mAllOnesPage;
};
//
// Character Map Compression
//
// Each font requires its own 8k charmap. On a system with 200
// fonts this would take: 200 * 8K = 1600K memory.
//
// Since most char maps are mostly empty a significant amount
// of memory can be saved by not allocating the unused sections.
//
// If the map has one or more levels of indirection then the
// the empty sections of the map can all be folded to a single
// common empty element. In this way only the non-empty sections
// need space. Because the empty sections actually point to a
// common empty section every entry in the map can be valid
// without requiring actually allocating space.
// Some larger CJK fonts have large sections where every bit
// is set. In the same way that the empty sections are folded
// onto one "empty page", the sections where all bits are set are
// folded on to one "all bits set page" .
//
// Break up the Unicode range bits 0x0000 - 0xFFFF
// into 3 bit ranges:
//
// upper bits: bit15 - bit12
// mid bits: bit11 - bit8
// page bits: bit7 - bit0
//
// within a page, (assumming a 4 byte ALU)
// bits 7-5 select one of the 8 longs
// bits 4-0 select one of the 32 bits within the long
//
// There is exactly one upper "pointers" array.
//
// The upper pointers each point to a mid array. If there are no chars
// in an upper pointer's block that pointer points to the empty mid.
// Thus all upper pointers are "valid" even if they do not have space
// allocated; eg: the accessor macro does not need to test if the
// pointer is zero.
//
// Each mid pointer in the mid array points to a page. If there are no
// chars in a mid pointer's page that pointer points to the empty page.
// Thus all mid pointers are "valid" even if they do not have space
// allocated; eg: the accessor macro does not need to test if the
// pointer is zero.
//
// Since the array will be less than 5K PRUint16 the "pointers" can
// be implemented as 2 byte offsets from the base instead of
// real pointers.
//
// the format of the CCMap is
// the upper pointers (16 PRUint16)
// the empty mid pointers (16 PRUint16)
// the empty page (16 PRUint16)
// non-empty mid pointers and pages as needed
// One minor note: for a completely empty map it is actually
// possible to fold the upper, empty mid, and empty page
// on top of each other and make a map of only 32 bytes.
#define CCMAP_EMPTY_SIZE_PER_INT16 16
// offsets to the empty mid and empty page
#define CCMAP_EMPTY_MID CCMAP_NUM_UPPER_POINTERS
#define CCMAP_EMPTY_PAGE CCMAP_EMPTY_MID+CCMAP_NUM_MID_POINTERS
//
// Because the table is offset based the code can build the table in a
// temp space (max table size on the stack) and then do one alloc of
// the actual needed size and simply copy over the data.
//
//
// Compressed Char map surrogate extension
//
// The design goal of surrogate support extension is to keep efficiency
// and compatibility of existing compressed charmap operations. Most of
// existing operation are untouched. For BMP support, very little memory
// overhead (4 bytes) is added. Runtime efficiency of BMP support is
// unchanged.
//
// structure of extended charmap:
// ccmap flag 1 PRUint16 , indication if this is extended one or not
// bmp ccmap size 1 PRUint16 , the size of BMP ccmap,
// BMP ccmap size varies,
// plane index 16 PRUint32, use to index ccmap for non-BMP plane
// empty ccmap 16 PRUint16, a total empty ccmap
// non-BMP ccmaps size varies, other non-empty, non-BMP ccmap
//
// Changes to basic ccmap
// 2 PRUint16 are added in the very beginning. One is used to descript the size
// of the ccmap, the other is used as a flag. But these 2 fields are indexed
// negatively so that all other operation remain unchanged to keep efficiency.
// ccmap memory allocation is moved from nsCompressedCharMap::NewCCMap to
// MapToCCMap.
//
// Extended ccmap
// A 16*PRUint32 array was put at the end of basic ccmap, each PRUint32 either
// pointed to the empty ccmap or a independent plane ccmap. Directly after this
// array is a empty ccmap. All planes that has no character will share this ccmap.
// All non-empty plane will have a ccmap.
// "MapToCCMapExt" is added to created an extended ccmap, each plane ccmap is
// created the same as basic one, but without 2 additional fields.
// "HasGlyphExt" is used to access extended ccmap, it first need to locate the
// plane ccmap, and then operated the same way as "HasGlyph".
//
// Compatibility between old and new one
// Because extended ccmap include an exactly identical basic ccmap in its head,
// basic ccmap operation (HasGlyph) can be applied on extended ccmap without
// problem.
// Because basic ccmap is now have a flag to indicate if it is a extended one,
// Extended ccmap operation (HasGlyphExt) can check the flag before it does
// extended ccmap specific operation. So HasGlyphExt can be applied to basic ccmap
// too.
//
// Page bits
//
#define CCMAP_BITS_PER_PAGE_LOG2 8
#define CCMAP_BITS_PER_PAGE CCMAP_POW2(CCMAP_BITS_PER_PAGE_LOG2)
#define CCMAP_BIT_INDEX(c) ((c) & PR_BITMASK(CCMAP_BITS_PER_ALU_LOG2))
#define CCMAP_ALU_INDEX(c) (((c)>>CCMAP_BITS_PER_ALU_LOG2) \
& PR_BITMASK(CCMAP_BITS_PER_PAGE_LOG2 - CCMAP_BITS_PER_ALU_LOG2))
#define CCMAP_PAGE_MASK PR_BITMASK(CCMAP_BITS_PER_PAGE_LOG2)
#define CCMAP_NUM_PRUINT16S_PER_PAGE \
(CCMAP_BITS_PER_PAGE/CCMAP_BITS_PER_PRUINT16)
// one bit per char
#define CCMAP_NUM_ALUS_PER_PAGE (CCMAP_BITS_PER_PAGE/CCMAP_BITS_PER_ALU)
#define CCMAP_NUM_UCHARS_PER_PAGE CCMAP_BITS_PER_PAGE
//
// Mid bits
//
#define CCMAP_BITS_PER_MID_LOG2 4
#define CCMAP_MID_INDEX(c) \
(((c)>>CCMAP_BITS_PER_PAGE_LOG2) & PR_BITMASK(CCMAP_BITS_PER_MID_LOG2))
#define CCMAP_NUM_MID_POINTERS CCMAP_POW2(CCMAP_BITS_PER_MID_LOG2)
#define CCMAP_NUM_UCHARS_PER_MID \
CCMAP_POW2(CCMAP_BITS_PER_MID_LOG2+CCMAP_BITS_PER_PAGE_LOG2)
//
// Upper bits
//
#define CCMAP_BITS_PER_UPPER_LOG2 4
#define CCMAP_UPPER_INDEX(c) \
(((c)>>(CCMAP_BITS_PER_MID_LOG2+CCMAP_BITS_PER_PAGE_LOG2)) \
& PR_BITMASK(CCMAP_BITS_PER_UPPER_LOG2))
#define CCMAP_NUM_UPPER_POINTERS CCMAP_POW2(CCMAP_BITS_PER_UPPER_LOG2)
//
// Misc
//
#define CCMAP_BITS_PER_PRUINT16_LOG2 4
#define CCMAP_BITS_PER_PRUINT32_LOG2 5
#define CCMAP_BITS_PER_PRUINT16 CCMAP_POW2(CCMAP_BITS_PER_PRUINT16_LOG2)
#define CCMAP_BITS_PER_PRUINT32 CCMAP_POW2(CCMAP_BITS_PER_PRUINT32_LOG2)
#define CCMAP_BITS_PER_ALU CCMAP_POW2(CCMAP_BITS_PER_ALU_LOG2)
#define CCMAP_ALUS_PER_PRUINT32 (CCMAP_BITS_PER_PRUINT32/CCMAP_BITS_PER_ALU)
#define CCMAP_PRUINT32S_PER_ALU (CCMAP_BITS_PER_ALU/CCMAP_BITS_PER_PRUINT32)
#define CCMAP_PRUINT32S_PER_PAGE (CCMAP_BITS_PER_PAGE/CCMAP_BITS_PER_PRUINT32)
#define CCMAP_ALU_MASK PR_BITMASK(CCMAP_BITS_PER_ALU)
#define CCMAP_ALUS_PER_PAGE CCMAP_POW2(CCMAP_BITS_PER_PAGE_LOG2 \
- CCMAP_BITS_PER_ALU_LOG2)
#define NUM_UNICODE_CHARS CCMAP_POW2(CCMAP_BITS_PER_UPPER_LOG2 \
+CCMAP_BITS_PER_MID_LOG2 \
+CCMAP_BITS_PER_PAGE_LOG2)
#define CCMAP_TOTAL_PAGES CCMAP_POW2(CCMAP_BITS_PER_UPPER_LOG2 \
+CCMAP_BITS_PER_MID_LOG2)
#define CCMAP_BEGIN_AT_START_OF_MAP 0xFFFF
//
// Finally, build up the macro to test the bit for a given char
//
// offset from base to mid array
#define CCMAP_TO_MID(m,c) ((m)[CCMAP_UPPER_INDEX(c)])
// offset from base to page
#define CCMAP_TO_PAGE(m,c) ((m)[CCMAP_TO_MID((m),(c)) + CCMAP_MID_INDEX(c)])
// offset from base to alu
#define CCMAP_TO_ALU(m,c) \
(*((ALU_TYPE*)(&((m)[CCMAP_TO_PAGE((m),(c))])) + CCMAP_ALU_INDEX(c)))
// test the bit
#define CCMAP_HAS_CHAR(m,c) (((CCMAP_TO_ALU(m,c))>>CCMAP_BIT_INDEX(c)) & 1)
// unset the bit
#define CCMAP_UNSET_CHAR(m,c) (CCMAP_TO_ALU(m,c) &= ~(CCMAP_POW2(CCMAP_BIT_INDEX(c))))
#define CCMAP_SIZE(m) (*((m)-1))
#define CCMAP_FLAG(m) (*((m)-2))
#define CCMAP_EXTRA (sizeof(ALU_TYPE)/sizeof(PRUint16)>2? sizeof(ALU_TYPE)/sizeof(PRUint16): 2)
#define CCMAP_SURROGATE_FLAG 0X0001
#define CCMAP_NONE_FLAG 0x0000
// non-bmp unicode support extension
#define EXTENDED_UNICODE_PLANES 16
// get plane number from ccmap, bmp excluded, so plane 1's number is 0.
#define CCMAP_PLANE_FROM_SURROGATE(h) ((((PRUint16)(h) - (PRUint16)0xd800) >> 6) + 1)
// same as above, but get plane number from a ucs4 char
#define CCMAP_PLANE(u) ((((PRUint32)(u))>>16))
// scalar value inside the plane
#define CCMAP_INPLANE_OFFSET(h, l) (((((PRUint16)(h) - (PRUint16)0xd800) & 0x3f) << 10) + ((PRUint16)(l) - (PRUint16)0xdc00))
// get ccmap for that plane
#define CCMAP_FOR_PLANE_EXT(m, i) ((m) + ((PRUint32*)((m) + CCMAP_SIZE(m)))[(i)-1])
// test the bit for surrogate pair
#define CCMAP_HAS_CHAR_EXT2(m, h, l) (CCMAP_FLAG(m)&CCMAP_SURROGATE_FLAG && \
CCMAP_HAS_CHAR(CCMAP_FOR_PLANE_EXT((m), CCMAP_PLANE_FROM_SURROGATE(h)), CCMAP_INPLANE_OFFSET(h, l)))
// test the bit for a character in UCS4
#define CCMAP_HAS_CHAR_EXT(m, ucs4) (!((ucs4)&0xffff0000) && CCMAP_HAS_CHAR(m, (PRUnichar)(ucs4)) || \
CCMAP_FLAG(m)&CCMAP_SURROGATE_FLAG && CCMAP_HAS_CHAR(CCMAP_FOR_PLANE_EXT((m), CCMAP_PLANE(ucs4)), (ucs4)&0xffff))
#endif // NSCOMPRESSEDCHARMAP_H

View File

@@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSCOORD_H
#define NSCOORD_H
#include "nscore.h"
/*
* Basic type used for the geometry classes. By making it a typedef we can
* easily change it in the future.
*
* All coordinates are maintained as signed 32-bit integers in the twips
* coordinate space. A twip is 1/20th of a point, and there are 72 points per
* inch.
*
* Twips are used because they are a device-independent unit of measure. See
* header file nsUnitConversion.h for many useful macros to convert between
* different units of measure.
*/
typedef PRInt32 nscoord;
#endif /* NSCOORD_H */

View File

@@ -1,184 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <Roland.Mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContext_h___
#define nsDeviceContext_h___
#include "nsIDeviceContext.h"
#include "nsIDeviceContextSpec.h"
#include "nsCOMPtr.h"
#include "nsIAtom.h"
#include "nsVoidArray.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsWeakReference.h"
class nsIImageRequest;
class nsHashtable;
class nsFontCache
{
public:
nsFontCache();
virtual ~nsFontCache();
NS_IMETHOD Init(nsIDeviceContext* aContext);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext) const;
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
nsIFontMetrics *&aMetrics);
nsresult FontMetricsDeleted(const nsIFontMetrics* aFontMetrics);
nsresult Compact();
nsresult Flush();
/* printer device context classes may create their own
* subclasses of nsFontCache (and override this method) and override
* DeviceContextImpl::CreateFontCache (see bug 81311).
*/
NS_IMETHOD CreateFontMetricsInstance(nsIFontMetrics** fm);
protected:
nsVoidArray mFontMetrics;
nsIDeviceContext *mContext; // we do not addref this since
// ownership is implied. MMP.
};
class NS_GFX DeviceContextImpl : public nsIDeviceContext,
public nsIObserver,
public nsSupportsWeakReference
{
public:
DeviceContextImpl();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_IMETHOD Init(nsNativeWidget aWidget);
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext){return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow);
NS_IMETHOD GetDevUnitsToTwips(float &aDevUnitsToTwips) const;
NS_IMETHOD GetTwipsToDevUnits(float &aTwipsToDevUnits) const;
NS_IMETHOD SetAppUnitsToDevUnits(float aAppUnits);
NS_IMETHOD SetDevUnitsToAppUnits(float aDevUnits);
NS_IMETHOD GetAppUnitsToDevUnits(float &aAppUnits) const;
NS_IMETHOD GetDevUnitsToAppUnits(float &aDevUnits) const;
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const;
NS_IMETHOD SetCanonicalPixelScale(float aScale);
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
nsIFontMetrics*& aMetrics);
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics);
NS_IMETHOD SetZoom(float aZoom);
NS_IMETHOD GetZoom(float &aZoom) const;
NS_IMETHOD SetTextZoom(float aTextZoom);
NS_IMETHOD GetTextZoom(float &aTextZoom) const;
NS_IMETHOD GetGamma(float &aGamma);
NS_IMETHOD SetGamma(float aGamma);
NS_IMETHOD GetGammaTable(PRUint8 *&aGammaTable);
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
PRBool& aAliased);
NS_IMETHOD CreateFontCache();
NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics);
NS_IMETHOD FlushFontCache(void);
NS_IMETHOD GetDepth(PRUint32& aDepth);
NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo);
#ifdef NS_PRINT_PREVIEW
NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC);
NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC) { *aAltDC = mAltDC.get(); NS_IF_ADDREF(*aAltDC); return NS_OK;}
NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn);
#else
#endif
protected:
virtual ~DeviceContextImpl();
void CommonInit(void);
void SetGammaTable(PRUint8 * aTable, float aCurrentGamma, float aNewGamma);
nsresult CreateIconILGroupContext();
virtual nsresult CreateFontAliasTable();
nsresult AliasFont(const nsString& aFont,
const nsString& aAlias, const nsString& aAltAlias,
PRBool aForceAlias);
void GetLocaleLangGroup(void);
float mTwipsToPixels;
float mPixelsToTwips;
float mAppUnitsToDevUnits;
float mDevUnitsToAppUnits;
nsFontCache *mFontCache;
nsCOMPtr<nsIAtom> mLocaleLangGroup; // XXX temp fix for performance bug - erik
float mZoom;
float mTextZoom;
float mGammaValue;
PRUint8 *mGammaTable;
nsHashtable* mFontAliasTable;
float mCPixelScale;
#ifdef NS_PRINT_PREVIEW
nsCOMPtr<nsIDeviceContext> mAltDC;
PRUint8 mUseAltDC;
#endif
public:
nsNativeWidget mWidget;
#ifdef NS_DEBUG
PRBool mInitialized;
#endif
};
#endif /* nsDeviceContext_h___ */

View File

@@ -1,143 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFont_h___
#define nsFont_h___
#include "nscore.h"
#include "nsCoord.h"
#include "nsString.h"
// XXX we need a method to enumerate all of the possible fonts on the
// system across family, weight, style, size, etc. But not here!
// Enumerator callback function. Return PR_FALSE to stop
typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
// IDs for generic fonts
// NOTE: 0, 1 are reserved for the special IDs of the default variable
// and fixed fonts in the presentation context, see nsIPresContext.h
const PRUint8 kGenericFont_NONE = 0x00;
// Special
const PRUint8 kGenericFont_moz_variable = 0x00; // for the default variable width font
const PRUint8 kGenericFont_moz_fixed = 0x01; // our special "use the user's fixed font"
// CSS
const PRUint8 kGenericFont_serif = 0x02;
const PRUint8 kGenericFont_sans_serif = 0x04;
const PRUint8 kGenericFont_monospace = 0x08;
const PRUint8 kGenericFont_cursive = 0x10;
const PRUint8 kGenericFont_fantasy = 0x20;
// Font structure.
struct NS_GFX nsFont {
// The family name of the font
nsString name;
// The style of font (normal, italic, oblique)
PRUint8 style;
// The variant of the font (normal, small-caps)
PRUint8 variant;
// The weight of the font (0-999)
PRUint16 weight;
// The decorations on the font (underline, overline,
// line-through). The decorations can be binary or'd together.
PRUint8 decorations;
// The logical size of the font, in nscoord units
nscoord size;
// The aspect-value (ie., the ratio actualsize:actualxheight) that any
// actual physical font created from this font structure must have when
// rendering or measuring a string. A value of 0 means no adjustment
// needs to be done.
float sizeAdjust;
// Initialize the font struct with an iso-latin1 name
nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
float aSizeAdjust=0.0f);
// Initialize the font struct with a (potentially) unicode name
nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
float aSizeAdjust=0.0f);
// Make a copy of the given font
nsFont(const nsFont& aFont);
nsFont();
~nsFont();
PRBool operator==(const nsFont& aOther) const {
return Equals(aOther);
}
PRBool Equals(const nsFont& aOther) const ;
nsFont& operator=(const nsFont& aOther);
// Utility method to interpret name string
// enumerates all families specified by this font only
// returns PR_TRUE if completed, PR_FALSE if stopped
// enclosing quotes will be removed, and whitespace compressed (as needed)
PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
void GetFirstFamily(nsString& aFamily) const;
// Utility method to return the ID of a generic font
static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
};
#define NS_FONT_STYLE_NORMAL 0
#define NS_FONT_STYLE_ITALIC 1
#define NS_FONT_STYLE_OBLIQUE 2
#define NS_FONT_VARIANT_NORMAL 0
#define NS_FONT_VARIANT_SMALL_CAPS 1
#define NS_FONT_DECORATION_NONE 0x0
#define NS_FONT_DECORATION_UNDERLINE 0x1
#define NS_FONT_DECORATION_OVERLINE 0x2
#define NS_FONT_DECORATION_LINE_THROUGH 0x4
#define NS_FONT_WEIGHT_NORMAL 400
#define NS_FONT_WEIGHT_BOLD 700
#endif /* nsFont_h___ */

View File

@@ -1,110 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsGfxCIID_h__
#define nsGfxCIID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
#define NS_IMAGE_CID \
{ 0x6049b260, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_RENDERING_CONTEXT_CID \
{ 0x6049b261, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_CID \
{ 0x6049b262, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_FONT_METRICS_CID \
{ 0x6049b263, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_FONT_ENUMERATOR_CID \
{ 0xa6cf9115, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
#define NS_FONTLIST_CID \
{ 0x6a8c0dd4, 0x1dd2, 0x11b2, \
{ 0x9a, 0x8f, 0xf8, 0x2f, 0x9d, 0xf2, 0x5b, 0x07 } }
#define NS_REGION_CID \
{ 0xe12752f0, 0xee9a, 0x11d1, \
{ 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_SCRIPTABLE_REGION_CID \
{ 0xda5b130a, 0x1dd1, 0x11b2, \
{ 0xad, 0x47, 0xf4, 0x55, 0xb1, 0x81, 0x4a, 0x78 } }
#define NS_BLENDER_CID \
{ 0x6049b264, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_SPEC_CID \
{ 0xd7193600, 0x78e0, 0x11d2, \
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_SPEC_FACTORY_CID \
{ 0xec5bebb0, 0x7b51, 0x11d2, \
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DRAWING_SURFACE_CID \
{ 0x199c7040, 0xcab0, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_IMAGEMANAGER_CID \
{ 0x140d2dd1, 0x96f4, 0x11d3, \
{ 0x8a, 0xf3, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
#define NS_SCREENMANAGER_CID \
{ 0xc401eb80, 0xf9ea, 0x11d3, \
{ 0xbb, 0x6f, 0xe7, 0x32, 0xb7, 0x3e, 0xbe, 0x7c } }
#define NS_PRINTOPTIONS_CID \
{ 0x30a3b080, 0x4867, 0x11d4, \
{ 0xa8, 0x56, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } }
#define NS_PRINTER_ENUMERATOR_CID \
{ 0xa6cf9129, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
#endif

View File

@@ -1,100 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIBlender_h___
#define nsIBlender_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsIRenderingContext.h"
// IID for the nsIBlender interface
#define NS_IBLENDER_IID \
{ 0xbdb4b5b0, 0xf0db, 0x11d1, \
{ 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
//----------------------------------------------------------------------
// Blender interface
class nsIBlender : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBLENDER_IID)
/**
* Initialize the Blender
* @update dc 11/4/98
* @param aContext is where the blender can get info about the device its blending on
* @result The result of the initialization, NS_OK if no errors
*/
NS_IMETHOD Init(nsIDeviceContext *aContext) = 0;
/**
* NOTE: if we can make this static, that would be great. I don't think we can.
* Blend source and destination nsDrawingSurfaces. Both drawing surfaces
* will have bitmaps associated with them.
* @param aSX x offset into source drawing surface of blend area
* @param aSY y offset into source drawing surface of blend area
* @param aWidth width of blend area
* @param aHeight width of blend area
* @param aSrc source for the blending
* @param aDest destination for blending
* @param aDX x offset into destination drawing surface of blend area
* @param aDY y offset into destination drawing surface of blend area
* @param aSrcOpacity 0.0f -> 1.0f opacity value of source area. 1.0f indicates
* complete opacity.
* @param aSecondSrc an optional second source drawing surface which is used in
* conjunction with the background color parameters to determine
* which pixels to blend
* @param aSrcBackColor color of pixels in aSrc that should be
* considered "background" color
* @param aSecondSrcBackColor color of pixels in aSrc that should be
* considered "background" color
*/
NS_IMETHOD Blend(PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight,nsDrawingSurface aSrc,
nsDrawingSurface aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
nsDrawingSurface aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0)) = 0;
NS_IMETHOD Blend(PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight, nsIRenderingContext *aSrc,
nsIRenderingContext *aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
nsIRenderingContext *aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0)) = 0;
};
#endif

View File

@@ -1,500 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDeviceContext_h___
#define nsIDeviceContext_h___
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsRect.h"
#include "nsIWidget.h"
#include "nsIRenderingContext.h"
class nsIView;
class nsIFontMetrics;
class nsIWidget;
class nsIDeviceContextSpec;
class nsIAtom;
struct nsFont;
struct nsColor;
//a cross platform way of specifying a native device context
typedef void * nsNativeDeviceContext;
/* error codes for printer device contexts */
#define NS_ERROR_GFX_PRINTER_BASE (1) /* adjustable :-) */
/* Unix: print command (lp/lpr) not found */
#define NS_ERROR_GFX_PRINTER_CMD_NOT_FOUND \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+1)
/* Unix: print command returned an error */
#define NS_ERROR_GFX_PRINTER_CMD_FAILURE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+2)
/* no printer available (e.g. cannot find _any_ printer) */
#define NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+3)
/* _specified_ (by name) printer not found */
#define NS_ERROR_GFX_PRINTER_NAME_NOT_FOUND \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+4)
/* access to printer denied */
#define NS_ERROR_GFX_PRINTER_ACCESS_DENIED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+5)
/* invalid printer attribute (for example: unsupported paper size etc.) */
#define NS_ERROR_GFX_PRINTER_INVALID_ATTRIBUTE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+6)
/* printer not "ready" (offline ?) */
#define NS_ERROR_GFX_PRINTER_PRINTER_NOT_READY \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+8)
/* printer out of paper */
#define NS_ERROR_GFX_PRINTER_OUT_OF_PAPER \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+9)
/* generic printer I/O error */
#define NS_ERROR_GFX_PRINTER_PRINTER_IO_ERROR \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+10)
/* print-to-file: could not open output file */
#define NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+11)
/* print-to-file: I/O error while printing to file */
#define NS_ERROR_GFX_PRINTER_FILE_IO_ERROR \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+12)
/* print preview: needs at least one printer */
#define NS_ERROR_GFX_PRINTER_PRINTPREVIEW \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+13)
/* print: starting document */
#define NS_ERROR_GFX_PRINTER_STARTDOC \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+14)
/* print: ending document */
#define NS_ERROR_GFX_PRINTER_ENDDOC \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+15)
/* print: starting page */
#define NS_ERROR_GFX_PRINTER_STARTPAGE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+16)
/* print: ending page */
#define NS_ERROR_GFX_PRINTER_ENDPAGE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+17)
/* print: print while in print preview */
#define NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+18)
/**
* Conts need for Print Preview
*/
#ifdef NS_PRINT_PREVIEW
const PRUint8 kUseAltDCFor_NONE = 0x00; // Do not use the AltDC for anything
const PRUint8 kUseAltDCFor_FONTMETRICS = 0x01; // Use it for only getting the font metrics
const PRUint8 kUseAltDCFor_CREATERC_REFLOW = 0x02; // Use when creating RenderingContexts for Reflow
const PRUint8 kUseAltDCFor_CREATERC_PAINT = 0x04; // Use when creating RenderingContexts for Painting
const PRUint8 kUseAltDCFor_SURFACE_DIM = 0x08; // Use it for getting the Surface Dimensions
#endif
#define NS_IDEVICE_CONTEXT_IID \
{ 0x5931c580, 0xb917, 0x11d1, \
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
//a cross platform way of specifying a native palette handle
typedef void * nsPalette;
//structure used to return information about a device's palette capabilities
struct nsPaletteInfo {
PRPackedBool isPaletteDevice;
PRUint16 sizePalette; // number of entries in the palette
PRUint16 numReserved; // number of reserved palette entries
nsPalette palette; // native palette handle
};
typedef enum {
eSystemFont_Caption, // css2
eSystemFont_Icon,
eSystemFont_Menu,
eSystemFont_MessageBox,
eSystemFont_SmallCaption,
eSystemFont_StatusBar,
eSystemFont_Window, // css3
eSystemFont_Document,
eSystemFont_Workspace,
eSystemFont_Desktop,
eSystemFont_Info,
eSystemFont_Dialog,
eSystemFont_Button,
eSystemFont_PullDownMenu,
eSystemFont_List,
eSystemFont_Field,
eSystemFont_Tooltips, // moz
eSystemFont_Widget,
eSystemFont_Theme
} nsSystemFontID;
class nsIDeviceContext : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_IID)
/**
* Initialize the device context from a widget
* @param aWidget a native widget to initialize the device context from
* @return error status
*/
NS_IMETHOD Init(nsNativeWidget aWidget) = 0;
/**
* Create a rendering context and initialize it from an nsIView
* @param aView view to initialize context from
* @param aContext out parameter for new rendering context
* @return error status
*/
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) = 0;
/**
* Create a rendering context and initialize it from an nsIWidget
* @param aWidget widget to initialize context from
* @param aContext out parameter for new rendering context
* @return error status
*/
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) = 0;
/**
* Create a rendering context and initialize it. This API should *only* be called
* on device contexts whose SupportsNativeWidgets() method return PR_FALSE.
* @param aContext out parameter for new rendering context
* @return error status
*/
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext) = 0;
/**
* Initialize a rendering context from a widget. This method is only for use
* when a rendering context was obtained directly from a factory rather than
* through one of the Create* methods above.
* @param aContext rendering context to initialize
* @param aWindow widget to initialize context from
* @return error status
*/
NS_IMETHOD InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow) = 0;
/**
* Query the device to see if it supports native widgets. If not, then
* nsIWidget->Create() calls should be avoided.
* @param aSupportsWidgets out paramater. If PR_TRUE, then native widgets
* can be created.
* @return error status
*/
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets) = 0;
/**
* Obtain the size of a device unit relative to a Twip. A twip is 1/20 of
* a point (which is 1/72 of an inch).
* @param aDevUnitsToTwips out parameter for conversion value
* @return error status
*/
NS_IMETHOD GetDevUnitsToTwips(float &aDevUnitsToTwips) const = 0;
/**
* Obtain the size of a Twip relative to a device unit.
* @param aTwipsToDevUnits out parameter for conversion value
* @return error status
*/
NS_IMETHOD GetTwipsToDevUnits(float &aTwipsToDevUnits) const = 0;
/**
* Set the scale factor to convert units used by the application
* to device units. Typically, an application will query the device
* for twips to device units scale and then set the scale
* to convert from whatever unit the application wants to use
* to device units. From that point on, all other parts of the
* app can use the Get* methods below to figure out how
* to convert device units <-> app units.
* @param aAppUnits scale value to convert from application defined
* units to device units.
* @return error status
*/
NS_IMETHOD SetAppUnitsToDevUnits(float aAppUnits) = 0;
/**
* Set the scale factor to convert device units to units
* used by the application. This should generally be
* 1.0f / the value passed into SetAppUnitsToDevUnits().
* @param aDevUnits scale value to convert from device units to
* application defined units
* @return error status
*/
NS_IMETHOD SetDevUnitsToAppUnits(float aDevUnits) = 0;
/**
* Get the scale factor to convert from application defined
* units to device units.
* @param aAppUnits out paramater for scale value
* @return error status
*/
NS_IMETHOD GetAppUnitsToDevUnits(float &aAppUnits) const = 0;
/**
* Get the scale factor to convert from device units to
* application defined units.
* @param aDevUnits out paramater for scale value
* @return error status
*/
NS_IMETHOD GetDevUnitsToAppUnits(float &aDevUnits) const = 0;
/**
* Get the value used to scale a "standard" pixel to a pixel
* of the same physical size for this device. a standard pixel
* is defined as a pixel on display 0. this is used to make
* sure that entities defined in pixel dimensions maintain a
* constant relative size when displayed from one output
* device to another.
* @param aScale out parameter for scale value
* @return error status
*/
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const = 0;
/**
* Get the value used to scale a "standard" pixel to a pixel
* of the same physical size for this device. a standard pixel
* is defined as a pixel on display 0. this is used to make
* sure that entities defined in pixel dimensions maintain a
* constant relative size when displayed from one output
* device to another.
* @param aScale in parameter for scale value
* @return error status
*/
NS_IMETHOD SetCanonicalPixelScale(float aScale) = 0;
/**
* Get the width of a vertical scroll bar and the height
* of a horizontal scrollbar in application units.
* @param aWidth out parameter for width
* @param aHeight out parameter for height
* @return error status
*/
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const = 0;
/**
* Fill in an nsFont based on the ID of a system font. This function
* may or may not fill in the size, so the size should be set to a
* reasonable default before calling.
*
* @param aID The system font ID.
* @param aInfo The font structure to be filled in.
* @return error status
*/
NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const = 0;
/**
* Get the nsIFontMetrics that describe the properties of
* an nsFont.
* @param aFont font description to obtain metrics for
* @param aLangGroup the language group of the document
* @param aMetrics out parameter for font metrics
* @return error status
*/
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
nsIFontMetrics*& aMetrics) = 0;
/**
* Get the nsIFontMetrics that describe the properties of
* an nsFont.
* @param aFont font description to obtain metrics for
* @param aMetrics out parameter for font metrics
* @return error status
*/
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics) = 0;
//get and set the document zoom value used for display-time
//scaling. default is 1.0 (no zoom)
NS_IMETHOD SetZoom(float aZoom) = 0;
NS_IMETHOD GetZoom(float &aZoom) const = 0;
//get and set the text zoom value used for display-time
//scaling. default is 1.0 (no zoom)
NS_IMETHOD SetTextZoom(float aTextZoom) = 0;
NS_IMETHOD GetTextZoom(float &aTextZoom) const = 0;
//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
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface) = 0;
//functions for handling gamma correction of output device
NS_IMETHOD GetGamma(float &aGamms) = 0;
NS_IMETHOD SetGamma(float aGamma) = 0;
//XXX the return from this really needs to be ref counted somehow. MMP
NS_IMETHOD GetGammaTable(PRUint8 *&aGammaTable) = 0;
/**
* Check to see if a particular named font exists.
* @param aFontName character string of font face name
* @return NS_OK if font is available, else font is unavailable
*/
NS_IMETHOD CheckFontExistence(const nsString& aFaceName) = 0;
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName) = 0;
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
PRBool& aAliased) = 0;
/**
* Notification when a font metrics instance created for this device is
* about to be deleted
*/
NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics) = 0;
/**
* Attempt to free up resoruces by flushing out any fonts no longer
* referenced by anything other than the font cache itself.
* @return error status
*/
NS_IMETHOD FlushFontCache(void) = 0;
/**
* Return the bit depth of the device.
*/
NS_IMETHOD GetDepth(PRUint32& aDepth) = 0;
/**
* Returns information about the device's palette capabilities.
*/
NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo) = 0;
/**
* Returns Platform specific pixel value for an RGB value
*/
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel) = 0;
/**
* Get the size of the displayable area of the output device
* in app units.
* @param aWidth out parameter for width
* @param aHeight out parameter for height
* @return error status
*/
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) = 0;
/**
* Get the size of the content area of the output device in app units.
* This corresponds on a screen device, for instance, to the entire screen.
* @param aRect out parameter for full rect. Position (x,y) will be (0,0) or
* relative to the primary monitor if this is not the primary.
* @return error status
*/
NS_IMETHOD GetRect ( nsRect &aRect ) = 0;
/**
* Get the size of the content area of the output device in app units.
* This corresponds on a screen device, for instance, to the area reported
* by GetDeviceSurfaceDimensions, minus the taskbar (Windows) or menubar
* (Macintosh).
* @param aRect out parameter for client rect. Position (x,y) will be (0,0)
* adjusted for any upper/left non-client space if present or
* relative to the primary monitor if this is not the primary.
* @return error status
*/
NS_IMETHOD GetClientRect(nsRect &aRect) = 0;
/**
* Returns a new nsIDeviceContext suitable for the device context
* specification passed in.
* @param aDevice a device context specification. this is a platform
* specific structure that only a platform specific device
* context can interpret.
* @param aContext out parameter for new device context. nsnull on
* failure to create new device context.
* @return error status
*/
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext) = 0;
//XXX need to work out re-entrancy issues for these APIs... MMP
/**
* Inform the output device that output of a document is beginning
* Used for print related device contexts. Must be matched 1:1 with
* EndDocument().
* XXX needs to take parameters so that feedback can be given to the
* app regarding pagination progress and aborting print operations?
* @return error status
*/
NS_IMETHOD BeginDocument(PRUnichar * aTitle) = 0;
/**
* Inform the output device that output of a document is ending.
* Used for print related device contexts. Must be matched 1:1 with
* BeginDocument()
* @return error status
*/
NS_IMETHOD EndDocument(void) = 0;
/**
* Inform the output device that output of a page is beginning
* Used for print related device contexts. Must be matched 1:1 with
* EndPage() and within a BeginDocument()/EndDocument() pair.
* @return error status
*/
NS_IMETHOD BeginPage(void) = 0;
/**
* Inform the output device that output of a page is ending
* Used for print related device contexts. Must be matched 1:1 with
* BeginPage() and within a BeginDocument()/EndDocument() pair.
* @return error status
*/
NS_IMETHOD EndPage(void) = 0;
#ifdef NS_PRINT_PREVIEW
/**
* Set an Alternative Device Context where some of the calls
* are deferred to it
*/
NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC) = 0;
/**
* Get the Alternate Device Context
*/
NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC) = 0;
/**
* Turn on/off which types of information is retrived
* via the alt device context
*/
NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn) = 0;
#endif
};
#endif /* nsIDeviceContext_h___ */

View File

@@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDeviceContextSpec_h___
#define nsIDeviceContextSpec_h___
#include "nsIDeviceContext.h"
#define NS_IDEVICE_CONTEXT_SPEC_IID \
{ 0x9951f910, 0x78d7, 0x11d2, \
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDeviceContextSpec : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID)
};
#endif

View File

@@ -1,87 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDeviceContextSpecFactory_h___
#define nsIDeviceContextSpecFactory_h___
#include "nsISupports.h"
class nsIDeviceContextSpec;
class nsIWidget;
class nsIPrintSettings;
#define NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID \
{ 0xf6669570, 0x7b3d, 0x11d2, \
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDeviceContextSpecFactory : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID)
/**
* Initialize the device context spec factory
* @return error status
*/
NS_IMETHOD Init(void) = 0;
/**
* Get a device context specification. Typically, this
* means getting information about a printer. A previously
* returned device context spec can be passed in and used as
* a starting point for getting a new spec (or simply returning
* the old spec again). Additionally, if it is desirable to
* get the device context spec without user intervention, any
* dialog boxes can be supressed by passing in PR_TRUE for the
* aQuiet parameter.
* @param aWidget.. this is a widget a dialog can be hosted in
* @param aNewSpec out parameter for device context spec returned. the
* aOldSpec may be returned if the object is recyclable.
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet) = 0;
};
#endif

View File

@@ -1,168 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDrawingSurface_h___
#define nsIDrawingSurface_h___
#include "nscore.h"
#include "nsISupports.h"
// a memory area that can be rendered to
typedef struct
{
PRUint32 mRedZeroMask; //red color mask in zero position
PRUint32 mGreenZeroMask; //green color mask in zero position
PRUint32 mBlueZeroMask; //blue color mask in zero position
PRUint32 mAlphaZeroMask; //alpha data mask in zero position
PRUint32 mRedMask; //red color mask
PRUint32 mGreenMask; //green color mask
PRUint32 mBlueMask; //blue color mask
PRUint32 mAlphaMask; //alpha data mask
PRUint8 mRedCount; //number of red color bits
PRUint8 mGreenCount; //number of green color bits
PRUint8 mBlueCount; //number of blue color bits
PRUint8 mAlphaCount; //number of alpha data bits
PRUint8 mRedShift; //number to shift value into red position
PRUint8 mGreenShift; //number to shift value into green position
PRUint8 mBlueShift; //number to shift value into blue position
PRUint8 mAlphaShift; //number to shift value into alpha position
} nsPixelFormat;
#define RASWIDTH(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
#define NS_IDRAWING_SURFACE_IID \
{ 0x61cc77e0, 0xcaac, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDrawingSurface : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAWING_SURFACE_IID)
/**
* Lock a rect of a drawing surface and return a
* pointer to the upper left hand corner of the
* bitmap.
* @param aX x position of subrect of bitmap
* @param aY y position of subrect of bitmap
* @param aWidth width of subrect of bitmap
* @param aHeight height of subrect of bitmap
* @param aBits out parameter for upper left hand
* corner of bitmap
* @param aStride out parameter for number of bytes
* to add to aBits to go from scanline to scanline
* @param aWidthBytes out parameter for number of
* bytes per line in aBits to process aWidth pixels
* @return error status
*
**/
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags) = 0;
/**
* Unlock a rect of a drawing surface. must be preceded
* by a call to Lock(). Lock()/Unlock() pairs do not nest.
* @return error status
*
**/
NS_IMETHOD Unlock(void) = 0;
/**
* Get the dimensions of a drawing surface
* @param aWidth out parameter for width of drawing surface
* @param aHeight out parameter for height of drawing surface
* @return error status
*
**/
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight) = 0;
/**
* Get the offscreen status of the drawing surface
* @param aOffscreen out parameter for offscreen status of
* drawing surface. if PR_TRUE, then modifying the
* drawing surface does not immediately reflect the
* changes on the output device
* @return error status
*
**/
NS_IMETHOD IsOffscreen(PRBool *aOffScreen) = 0;
/**
* Get the pixel addressability status of the drawing surface
* @param aAddressable out parameter for pixel addressability
* status of drawing surface. if PR_TRUE, then the
* drawing surface is optimized for pixel addressability
* (i.e. the Lock() method has very low overhead). All
* drawing surfaces support Lock()ing, but doing so on
* drawing surfaces that do not return PR_TRUE here may
* impose significant overhead.
* @return error status
*
**/
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable) = 0;
/**
* Get the pixel format of a drawing surface
* @param aOffscreen out parameter filled in with pixel
* format information.
* @return error status
*
**/
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat) = 0;
};
//when creating a drawing surface, you can use this
//to tell the drawing surface that you anticipate
//the need to get to the actual bits of the drawing
//surface at some point during it's lifetime. typically
//used when creating bitmaps to be operated on by the
//nsIBlender implementations.
#define NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS 0x0001
//flag to say that this drawing surface is shortlived,
//which may affect how the OS allocates it. Used for
//tiling, grouting etc.
#define NS_CREATEDRAWINGSURFACE_SHORTLIVED 0x0002
//when locking a drawing surface, use these flags to
//control how the data in the surface should be accessed
#define NS_LOCK_SURFACE_READ_ONLY 0x0001
#define NS_LOCK_SURFACE_WRITE_ONLY 0x0002
#endif // nsIDrawingSurface_h___

View File

@@ -1,228 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIFontMetrics_h___
#define nsIFontMetrics_h___
#include "nsISupports.h"
#include "nsCoord.h"
struct nsFont;
class nsString;
class nsIDeviceContext;
class nsIAtom;
// IID for the nsIFontMetrics interface
#define NS_IFONT_METRICS_IID \
{ 0xc74cb770, 0xa33e, 0x11d1, \
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
//----------------------------------------------------------------------
/**
* A native font handle
*/
typedef void* nsFontHandle;
/**
* Font metrics interface
*
* This interface may be somewhat misnamed. A better name might be
* nsIFontList. The style system uses the nsFont struct for various font
* properties, one of which is font-family, which can contain a *list* of
* font names. The nsFont struct is "realized" by asking the device context
* to cough up an nsIFontMetrics object, which contains a list of real font
* handles, one for each font mentioned in font-family (and for each fallback
* when we fall off the end of that list).
*
* The style system needs to have access to certain metrics, such as the
* em height (for the CSS "em" unit), and we use the first Western font's
* metrics for that purpose. The platform-specific implementations are
* expected to select non-Western fonts that "fit" reasonably well with the
* Western font that is loaded at Init time.
*/
class nsIFontMetrics : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
/**
* Initialize the font metrics. Call this after creating the font metrics.
* Font metrics you get from the font cache do NOT need to be initialized
*
* @see nsIDeviceContext#GetMetricsFor()
*/
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext *aContext) = 0;
/**
* Destroy this font metrics. This breaks the association between
* the font metrics and the device context.
*/
NS_IMETHOD Destroy() = 0;
/**
* Return the font's xheight property, scaled into app-units.
*/
NS_IMETHOD GetXHeight(nscoord& aResult) = 0;
/**
* Return the font's superscript offset (the distance from the
* baseline to where a superscript's baseline should be placed). The
* value returned will be a positive value.
*/
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult) = 0;
/**
* Return the font's subscript offset (the distance from the
* baseline to where a subscript's baseline should be placed). The
* value returned will be a positive value.
*/
NS_IMETHOD GetSubscriptOffset(nscoord& aResult) = 0;
/**
* Return the font's strikeout offset (the distance from the
* baseline to where a strikeout should be placed) and size
* Positive values are above the baseline, negative below.
*/
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize) = 0;
/**
* Return the font's underline offset (the distance from the
* baseline to where a underline should be placed) and size.
* Positive values are above the baseline, negative below.
*/
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
/**
* Returns the height (in app units) of the font. This is ascent plus descent
* plus any internal leading
*
* This method will be removed once the callers have been moved over to the
* new GetEmHeight (and possibly GetMaxHeight).
*/
NS_IMETHOD GetHeight(nscoord &aHeight) = 0;
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_MAC) || defined(XP_BEOS)
#define NEW_FONT_HEIGHT_APIS 1
#endif
#ifdef NEW_FONT_HEIGHT_APIS
/**
* Returns the normal line height (em height + leading).
*/
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight) = 0;
#endif /* NEW_FONT_HEIGHT_APIS */
/**
* Returns the amount of internal leading (in app units) for the font. This
* is computed as the "height - (ascent + descent)"
*/
NS_IMETHOD GetLeading(nscoord &aLeading) = 0;
#ifdef NEW_FONT_HEIGHT_APIS
/**
* Returns the height (in app units) of the Western font's em square. This is
* em ascent plus em descent.
*/
NS_IMETHOD GetEmHeight(nscoord &aHeight) = 0;
/**
* Returns, in app units, the ascent part of the Western font's em square.
*/
NS_IMETHOD GetEmAscent(nscoord &aAscent) = 0;
/**
* Returns, in app units, the descent part of the Western font's em square.
*/
NS_IMETHOD GetEmDescent(nscoord &aDescent) = 0;
/**
* Returns the height (in app units) of the Western font's bounding box.
* This is max ascent plus max descent.
*/
NS_IMETHOD GetMaxHeight(nscoord &aHeight) = 0;
#endif /* NEW_FONT_HEIGHT_APIS */
/**
* Returns, in app units, the maximum distance characters in this font extend
* above the base line.
*/
NS_IMETHOD GetMaxAscent(nscoord &aAscent) = 0;
/**
* Returns, in app units, the maximum distance characters in this font extend
* below the base line.
*/
NS_IMETHOD GetMaxDescent(nscoord &aDescent) = 0;
/**
* Returns, in app units, the maximum character advance for the font
*/
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance) = 0;
/**
* Returns the font associated with these metrics
*/
NS_IMETHOD GetFont(const nsFont *&aFont) = 0;
/**
* Returns the language group associated with these metrics
*/
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup) = 0;
/**
* Returns the font handle associated with these metrics
*/
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle) = 0;
#if defined(_WIN32) || defined(XP_OS2)
/**
* Returns the average character width
*/
NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth) = 0;
#endif
/**
* Returns the often needed width of the space character
*/
NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
};
#endif /* nsIFontMetrics_h___ */

View File

@@ -1,333 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIImage_h___
#define nsIImage_h___
#include "nsISupports.h"
#include "nsIRenderingContext.h"
struct nsRect;
class nsIDeviceContext;
struct nsColorMap
{
//I lifted this from the image lib. The difference is that
//this uses nscolor instead of NI_RGB. Multiple color pollution
//is a bad thing. MMP
PRInt32 NumColors; // Number of colors in the colormap.
// A negative value can be used to denote a
// possibly non-unique set.
//nscolor *Map; // Colormap colors.
PRUint8 *Index; // NULL, if map is in index order, otherwise
// specifies the indices of the map entries. */
};
typedef enum {
nsMaskRequirements_kNoMask,
nsMaskRequirements_kNeeds1Bit,
nsMaskRequirements_kNeeds8Bit
} nsMaskRequirements;
#define nsImageUpdateFlags_kColorMapChanged 0x1
#define nsImageUpdateFlags_kBitsChanged 0x2
// IID for the nsIImage interface
#define NS_IIMAGE_IID \
{ 0x0b4faaa0, 0xaa3a, 0x11d1, \
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
// Interface to Images
class nsIImage : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGE_IID)
/**
* Build and initialize the nsIImage
* @param aWidth The width in pixels of the desired pixelmap
* @param aHeight The height in pixels of the desired pixelmap
* @param aDepth The number of bits per pixel for the pixelmap
* @param aMaskRequirements A flag indicating if a alpha mask should be allocated
*/
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements) = 0;
/**
* Get the number of bytes per pixel for this image
* @update - dwc 2/3/99
* @return - the number of bytes per pixel
*/
virtual PRInt32 GetBytesPix() = 0;
/**
* Get whether rows are organized top to bottom, or bottom to top
* @update - syd 3/29/99
* @return PR_TRUE if top to bottom, else PR_FALSE
*/
virtual PRBool GetIsRowOrderTopToBottom() = 0;
/**
* Get the width for the pixelmap
* @update - dwc 2/1/99
* @return The width in pixels for the pixelmap
*/
virtual PRInt32 GetWidth() = 0;
/**
* Get the height for the pixelmap
* @update - dwc 2/1/99
* @return The height in pixels for the pixelmap
*/
virtual PRInt32 GetHeight() = 0;
/**
* Set/Get the decoded dimensions for the pixelmap
* 01/11/2000 - pnunn
*/
NS_IMETHOD SetDecodedRect(PRInt32, PRInt32, PRInt32, PRInt32) = 0;
virtual PRInt32 GetDecodedX1() = 0;
virtual PRInt32 GetDecodedY1() = 0;
virtual PRInt32 GetDecodedX2() = 0;
virtual PRInt32 GetDecodedY2() = 0;
NS_IMETHOD SetNaturalWidth(PRInt32) = 0;
NS_IMETHOD SetNaturalHeight(PRInt32) = 0;
virtual PRInt32 GetNaturalWidth() = 0;
virtual PRInt32 GetNaturalHeight() = 0;
/**
* Get a pointer to the bits for the pixelmap, only if it is not optimized
* @update - dwc 2/1/99
* @return address of the DIB pixel array
*/
virtual PRUint8 * GetBits() = 0;
/**
* Get the number of bytes needed to get to the next scanline for the pixelmap
* @update - dwc 2/1/99
* @return The number of bytes in each scanline
*/
virtual PRInt32 GetLineStride() = 0;
/**
* Get whether this image has an alpha mask. Preferable to testing
* if GetAlphaBits() is non-null.
* @update - sfraser 10/19/99
* @return PR_TRUE if the image has an alpha mask, PR_FALSE otherwise
*/
virtual PRBool GetHasAlphaMask() = 0;
/**
* Get a pointer to the bits for the alpha mask
* @update - dwc 2/1/99
* @return address of the alpha mask pixel array
*/
virtual PRUint8 * GetAlphaBits() = 0;
/**
* Get the width of the alpha mask
* @update - dwc 2/1/99
* @return The width in pixels
*/
virtual PRInt32 GetAlphaWidth() = 0;
/**
* Get the height of the alpha mask
* @update - dwc 2/1/99
* @return The width in pixels
*/
virtual PRInt32 GetAlphaHeight() = 0;
/**
* Get the number of bytes per scanline for the alpha mask
* @update - dwc 2/1/99
* @return The number of bytes in each scanline
*/
virtual PRInt32 GetAlphaLineStride() = 0;
/**
* Update the nsIImage color table
* @update - dwc 2/1/99
* @param aFlags Used to pass in parameters for the update
* @param aUpdateRect The rectangle to update
*/
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect) = 0;
/**
* Returns if the pixelmap has been converted to an optimized pixelmap
* @update - dwc 2/1/99
* @return If true, it is optimized
*/
virtual PRBool IsOptimized() = 0;
/**
* Converted this pixelmap to an optimized pixelmap for the device
* @update - dwc 2/1/99
* @param aContext The device to optimize for
* @return the result of the operation, if NS_OK, then the pixelmap is optimized
*/
virtual nsresult Optimize(nsIDeviceContext* aContext) = 0;
/**
* Get the colormap for the nsIImage
* @update - dwc 2/1/99
* @return if non null, the colormap for the pixelmap,otherwise the image is not color mapped
*/
virtual nsColorMap * GetColorMap() = 0;
/**
* BitBlit the nsIImage to a device, the source can be scaled to the dest
* @update - dwc 2/1/99
* @param aSurface the surface to blit to
* @param aX The destination horizontal location
* @param aY The destination vertical location
* @param aWidth The destination width of the pixelmap
* @param aHeight The destination height of the pixelmap
* @return if TRUE, no errors
*/
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* BitBlit the nsIImage to a device, the source and dest can be scaled
* @update - dwc 2/1/99
* @param aSurface the surface to blit to
* @param aSX The source width of the pixelmap
* @param aSY The source vertical location
* @param aSWidth The source width of the pixelmap
* @param aSHeight The source height of the pixelmap
* @param aDX The destination horizontal location
* @param aDY The destination vertical location
* @param aDWidth The destination width of the pixelmap
* @param aDHeight The destination height of the pixelmap
* @return if TRUE, no errors
*/
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
const nsRect &aTileRect) = 0;
/**
* BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled
* @update - saari 03/08/01
* @param aDstImage the nsImage to blit to
* @param aDX The destination horizontal location
* @param aDY The destination vertical location
* @param aDWidth The destination width of the pixelmap
* @param aDHeight The destination height of the pixelmap
* @return if TRUE, no errors
*/
NS_IMETHOD DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
/**
* Set the alpha level for the image
* @update - dwc 2/1/99
* @param the alpha level to set for the image, from 0 to 100%
*/
virtual void SetAlphaLevel(PRInt32 aAlphaLevel) = 0;
/**
* Get the alpha level for the image
* @update - dwc 2/1/99
* @return the alpha level for the image, from 0 to 100%
*/
virtual PRInt32 GetAlphaLevel() = 0;
/**
* 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() = 0;
/**
* Return information about the bits for this structure
* @update - dwc 2/1/99
* @return a bitmap info structure for the Device Dependent Bits
*/
virtual void* GetBitInfo() = 0;
/**
* LockImagePixels
* Lock the image pixels so that we can access them directly,
* with safely. May be a noop on some platforms.
*
* aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
*
* Must be balanced by a call to UnlockImagePixels().
*
* @update - sfraser 10/18/99
* @return error result
*/
NS_IMETHOD LockImagePixels(PRBool aMaskPixels) = 0;
/**
* UnlockImagePixels
* Unlock the image pixels. May be a noop on some platforms.
*
* Should balance an earlier call to LockImagePixels().
*
* aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
*
* @update - sfraser 10/18/99
* @return error result
*/
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels) = 0;
//get the color space metrics for this image
//virtual NI_ColorSpec * GetColorSpec() = 0; fix
//get the color which should be considered transparent.
//if this image is color mapped, this value will be an
//index into the color map. hokey? yes, but it avoids
//another silly api or struct.
//virtual nscolor GetTransparentColor() = 0; fix.
};
//change notification API flag bits
#define NS_IMAGE_UPDATE_COLORMAP 1
#define NS_IMAGE_UPDATE_PIXELS 2
#define NS_IMAGE_UPDATE_ALPHA 4
#endif

View File

@@ -1,94 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Patrick C. Beard <beard@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIPrintingContextMac_h___
#define nsIPrintingContextMac_h___
#include "nsISupports.h"
class nsIPrintSettings;
// 3d5917da-1dd2-11b2-bc7b-aa83823362e0
#define NS_IPRINTING_CONTEXT_IID \
{ 0x3d5917da, 0x1dd2, 0x11b2, \
{ 0xbc, 0x7b, 0xaa, 0x83, 0x82, 0x33, 0x62, 0xe0 } }
class nsIPrintingContext : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRINTING_CONTEXT_IID)
/**
* Initialize the printing context for use.
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet) = 0;
/**
* This will tell if the printmanager is currently open
* @update dc 12/03/98
* @param aIsOpen True or False depending if the printmanager is open
* @return error status
*/
NS_IMETHOD PrintManagerOpen(PRBool* aIsOpen) = 0;
/**
* Closes the printmanager if it is open.
* @update dc 12/03/98
* @return error status
*/
NS_IMETHOD ClosePrintManager() = 0;
NS_IMETHOD BeginDocument() = 0;
NS_IMETHOD EndDocument() = 0;
NS_IMETHOD BeginPage() = 0;
NS_IMETHOD EndPage() = 0;
NS_IMETHOD GetPrinterResolution(double* aResolution) = 0;
NS_IMETHOD GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight) = 0;
};
#endif /* nsIPrintingContextMac_h___ */

View File

@@ -1,279 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIRegion_h___
#define nsIRegion_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsRect.h"
enum nsRegionComplexity
{
eRegionComplexity_empty = 0,
eRegionComplexity_rect = 1,
eRegionComplexity_complex = 2
};
typedef struct
{
PRInt32 x;
PRInt32 y;
PRUint32 width;
PRUint32 height;
} nsRegionRect;
typedef struct
{
PRUint32 mNumRects; //number of actual rects in the mRects array
PRUint32 mRectsLen; //length, in rects, of the mRects array
PRUint32 mArea; //area of the covered portion of the region
nsRegionRect mRects[1];
} nsRegionRectSet;
// An implementation of a region primitive that can be used to
// represent arbitrary pixel areas. Probably implemented on top
// of the native region primitive. The assumption is that, at worst,
// it is a rectangle list.
#define NS_IREGION_IID \
{ 0x8ef366e0, 0xee94, 0x11d1, \
{ 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIRegion : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IREGION_IID)
virtual nsresult Init(void) = 0;
/**
* copy operator equivalent that takes another region
*
* @param region to copy
* @return void
*
**/
virtual void SetTo(const nsIRegion &aRegion) = 0;
/**
* copy operator equivalent that takes a rect
*
* @param aX xoffset of rect to set region to
* @param aY yoffset of rect to set region to
* @param aWidth width of rect to set region to
* @param aHeight height of rect to set region to
* @return void
*
**/
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* destructively intersect another region with this one
*
* @param region to intersect
* @return void
*
**/
virtual void Intersect(const nsIRegion &aRegion) = 0;
/**
* destructively intersect a rect with this region
*
* @param aX xoffset of rect to intersect with region
* @param aY yoffset of rect to intersect with region
* @param aWidth width of rect to intersect with region
* @param aHeight height of rect to intersect with region
* @return void
*
**/
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* destructively union another region with this one
*
* @param region to union
* @return void
*
**/
virtual void Union(const nsIRegion &aRegion) = 0;
/**
* destructively union a rect with this region
*
* @param aX xoffset of rect to union with region
* @param aY yoffset of rect to union with region
* @param aWidth width of rect to union with region
* @param aHeight height of rect to union with region
* @return void
*
**/
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* destructively subtract another region with this one
*
* @param region to subtract
* @return void
*
**/
virtual void Subtract(const nsIRegion &aRegion) = 0;
/**
* destructively subtract a rect from this region
*
* @param aX xoffset of rect to subtract with region
* @param aY yoffset of rect to subtract with region
* @param aWidth width of rect to subtract with region
* @param aHeight height of rect to subtract with region
* @return void
*
**/
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* is this region empty? i.e. does it contain any pixels
*
* @param none
* @return returns whether the region is empty
*
**/
virtual PRBool IsEmpty(void) = 0;
/**
* == operator equivalent i.e. do the regions contain exactly
* the same pixels
*
* @param region to compare
* @return whether the regions are identical
*
**/
virtual PRBool IsEqual(const nsIRegion &aRegion) = 0;
/**
* returns the bounding box of the region i.e. the smallest
* rectangle that completely contains the region.
*
* @param aX out parameter for xoffset of bounding rect for region
* @param aY out parameter for yoffset of bounding rect for region
* @param aWidth out parameter for width of bounding rect for region
* @param aHeight out parameter for height of bounding rect for region
* @return void
*
**/
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) = 0;
/**
* offsets the region in x and y
*
* @param xoffset pixel offset in x
* @param yoffset pixel offset in y
* @return void
*
**/
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset) = 0;
/**
* does the region intersect the rectangle?
*
* @param rect to check for containment
* @return true if the region intersects the rect
*
**/
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* get the set of rects which make up this region. the aRects
* parameter must be freed by calling FreeRects before the region
* is deleted. aRects may be passed in again when requesting
* the rect list as a recycling method.
*
* @param aRects out parameter containing set of rects
* comprising the region
* @return error status
*
**/
NS_IMETHOD GetRects(nsRegionRectSet **aRects) = 0;
/**
* Free a rect set returned by GetRects.
*
* @param aRects rects to free
* @return error status
*
**/
NS_IMETHOD FreeRects(nsRegionRectSet *aRects) = 0;
/**
* Get the native region that this nsIRegion represents.
* @param aRegion out parameter for native region handle
* @return error status
**/
NS_IMETHOD GetNativeRegion(void *&aRegion) const = 0;
/**
* Get the complexity of the region as defined by the
* nsRegionComplexity enum.
* @param aComplexity out parameter for region complexity
* @return error status
**/
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const = 0;
/**
* get the number of rects which make up this region.
*
* @param aRects out parameter containing the number of rects
* comprising the region
* @return error status
*
**/
NS_IMETHOD GetNumRects(PRUint32 *aRects) const = 0;
};
#endif // nsIRegion_h___

File diff suppressed because it is too large Load Diff

View File

@@ -1,80 +0,0 @@
/* -*- 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" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributors:
*/
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsColor.h"
struct nsRect;
struct nsSize;
struct nsFont;
struct nsMargin;
class nsIPresContext;
class nsIRenderingContext;
class nsIDeviceContext;
class nsIFrame;
class nsIAtom;
// IID for the nsITheme interface
// {F791038C-F97E-4068-A542-0343AE440664}
#define NS_ITHEME_IID \
{ 0xf791038c, 0xf97e, 0x4068, { 0xa5, 0x42, 0x3, 0x43, 0xae, 0x44, 0x6, 0x64 } }
// {D930E29B-6909-44e5-AB4B-AF10D6923705}
#define NS_THEMERENDERER_CID \
{ 0xd930e29b, 0x6909, 0x44e5, { 0xab, 0x4b, 0xaf, 0x10, 0xd6, 0x92, 0x37, 0x5 } }
class nsITheme: public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_ITHEME_IID; return iid; }
NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
nsIFrame* aFrame,
PRUint8 aWidgetType,
const nsRect& aRect,
const nsRect& aClipRect)=0;
NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext,
nsIFrame* aFrame,
PRUint8 aWidgetType,
nsMargin* aResult)=0;
NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
PRUint8 aWidgetType,
nsSize* aResult,
PRBool* aIsOverridable)=0;
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
nsIAtom* aAttribute, PRBool* aShouldRepaint)=0;
NS_IMETHOD ThemeChanged()=0;
virtual PRBool ThemeSupportsWidget(nsIPresContext* aPresContext,
PRUint8 aWidgetType)=0;
virtual PRBool WidgetIsContainer(PRUint8 aWidgetType)=0;
};
// Creator function
extern NS_METHOD NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult);

View File

@@ -1,91 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSMARGIN_H
#define NSMARGIN_H
#include "nsCoord.h"
struct nsMargin {
nscoord left, top, right, bottom;
// Constructors
nsMargin() {}
nsMargin(const nsMargin& aMargin) {*this = aMargin;}
nsMargin(nscoord aLeft, nscoord aTop,
nscoord aRight, nscoord aBottom) {left = aLeft; top = aTop;
right = aRight; bottom = aBottom;}
void SizeTo(nscoord aLeft, nscoord aTop,
nscoord aRight, nscoord aBottom) {left = aLeft; top = aTop;
right = aRight; bottom = aBottom;}
void SizeBy(nscoord aLeft, nscoord aTop,
nscoord aRight, nscoord aBottom) {left += aLeft; top += aTop;
right += aRight; bottom += aBottom;}
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator
PRBool operator==(const nsMargin& aMargin) const {
return (PRBool) ((left == aMargin.left) && (top == aMargin.top) &&
(right == aMargin.right) && (bottom == aMargin.bottom));
}
PRBool operator!=(const nsMargin& aMargin) const {
return (PRBool) ((left != aMargin.left) || (top != aMargin.top) ||
(right != aMargin.right) || (bottom != aMargin.bottom));
}
nsMargin operator+(const nsMargin& aMargin) const {
return nsMargin(left + aMargin.left, top + aMargin.top,
right + aMargin.right, bottom + aMargin.bottom);
}
nsMargin operator-(const nsMargin& aMargin) const {
return nsMargin(left - aMargin.left, top - aMargin.top,
right - aMargin.right, bottom - aMargin.bottom);
}
nsMargin& operator+=(const nsMargin& aMargin) {left += aMargin.left;
top += aMargin.top;
right += aMargin.right;
bottom += aMargin.bottom;
return *this;}
nsMargin& operator-=(const nsMargin& aMargin) {left -= aMargin.left;
top -= aMargin.top;
right -= aMargin.right;
bottom -= aMargin.bottom;
return *this;}
};
#endif /* NSMARGIN_H */

View File

@@ -1,141 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSPOINT_H
#define NSPOINT_H
#include "nsCoord.h"
struct nsPoint {
nscoord x, y;
// Constructors
nsPoint() {}
nsPoint(const nsPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
nsPoint(nscoord aX, nscoord aY) {x = aX; y = aY;}
void MoveTo(nscoord aX, nscoord aY) {x = aX; y = aY;}
void MoveBy(nscoord aDx, nscoord aDy) {x += aDx; y += aDy;}
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator
PRBool operator==(const nsPoint& aPoint) const {
return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
}
PRBool operator!=(const nsPoint& aPoint) const {
return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
}
nsPoint operator+(const nsPoint& aPoint) const {
return nsPoint(x + aPoint.x, y + aPoint.y);
}
nsPoint operator-(const nsPoint& aPoint) const {
return nsPoint(x - aPoint.x, y - aPoint.y);
}
nsPoint& operator+=(const nsPoint& aPoint) {
x += aPoint.x;
y += aPoint.y;
return *this;
}
nsPoint& operator-=(const nsPoint& aPoint) {
x -= aPoint.x;
y -= aPoint.y;
return *this;
}
};
/** ---------------------------------------------------
* A point structure with floats for the Quadratic bezier curve
* @update 4/27/2000 dwc
*/
struct nsFloatPoint {
float x, y;
// Constructors
nsFloatPoint() {}
nsFloatPoint(const nsFloatPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
nsFloatPoint(float aX, float aY) {x = aX; y = aY;}
void MoveTo(float aX, float aY) {x = aX; y = aY;}
void MoveTo(nscoord aX, nscoord aY) {x = (float)aX; y = (float)aY;}
void MoveBy(float aDx, float aDy) {x += aDx; y += aDy;}
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator
PRBool operator==(const nsFloatPoint& aPoint) const {
return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
}
PRBool operator!=(const nsFloatPoint& aPoint) const {
return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
}
nsFloatPoint operator+(const nsFloatPoint& aPoint) const {
return nsFloatPoint(x + aPoint.x, y + aPoint.y);
}
nsFloatPoint operator-(const nsFloatPoint& aPoint) const {
return nsFloatPoint(x - aPoint.x, y - aPoint.y);
}
nsFloatPoint& operator+=(const nsFloatPoint& aPoint) {
x += aPoint.x;
y += aPoint.y;
return *this;
}
nsFloatPoint& operator-=(const nsFloatPoint& aPoint) {
x -= aPoint.x;
y -= aPoint.y;
return *this;
}
};
/** ---------------------------------------------------
* A special type of point which also add the capability to tell if a point is on
* the curve.. or off of the curve for a path
* @update 03/29/00 dwc
*/
struct nsPathPoint: public nsFloatPoint{
PRBool mIsOnCurve;
// Constructors
nsPathPoint() {}
nsPathPoint(const nsPathPoint& aPoint) {x = aPoint.x; y = aPoint.y;mIsOnCurve=aPoint.mIsOnCurve;}
nsPathPoint(float aX, float aY) {x = aX; y = aY;mIsOnCurve=PR_TRUE;}
nsPathPoint(float aX, float aY,PRBool aIsOnCurve) {x = aX; y = aY;mIsOnCurve=aIsOnCurve;}
};
#endif /* NSPOINT_H */

View File

@@ -1,152 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSRECT_H
#define NSRECT_H
#include <stdio.h>
#include "nsCoord.h"
#include "nsPoint.h"
#include "nsSize.h"
#include "nsMargin.h"
#include "nsUnitConversion.h"
struct NS_GFX nsRect {
nscoord x, y;
nscoord width, height;
// Constructors
nsRect() : x(0), y(0), width(0), height(0) {}
nsRect(const nsRect& aRect) {*this = aRect;}
nsRect(const nsPoint& aOrigin, const nsSize &aSize) {x = aOrigin.x; y = aOrigin.y;
width = aSize.width; height = aSize.height;}
nsRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) {x = aX; y = aY;
width = aWidth; height = aHeight;}
// Emptiness. An empty rect is one that has no area, i.e. its height or width
// is <= 0
PRBool IsEmpty() const {
return (PRBool) ((height <= 0) || (width <= 0));
}
void Empty() {width = height = 0;}
// Containment
PRBool Contains(const nsRect& aRect) const;
PRBool Contains(nscoord aX, nscoord aY) const;
PRBool Contains(const nsPoint& aPoint) const {return Contains(aPoint.x, aPoint.y);}
// Intersection. Returns TRUE if the receiver overlaps aRect and
// FALSE otherwise
PRBool Intersects(const nsRect& aRect) const;
// Computes the area in which aRect1 and aRect2 overlap, and fills 'this' with
// the result. Returns FALSE if the rectangles don't intersect, and sets 'this'
// rect to be an empty rect.
//
// 'this' can be the same object as either aRect1 or aRect2
PRBool IntersectRect(const nsRect& aRect1, const nsRect& aRect2);
// Computes the smallest rectangle that contains both aRect1 and aRect2 and
// fills 'this' with the result. Returns FALSE and sets 'this' rect to be an
// empty rect if both aRect1 and aRect2 are empty
//
// 'this' can be the same object as either aRect1 or aRect2
PRBool UnionRect(const nsRect& aRect1, const nsRect& aRect2);
// Accessors
void SetRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) {
x = aX; y = aY; width = aWidth; height = aHeight;
}
void MoveTo(nscoord aX, nscoord aY) {x = aX; y = aY;}
void MoveTo(const nsPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
void MoveBy(nscoord aDx, nscoord aDy) {x += aDx; y += aDy;}
void SizeTo(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
void SizeTo(const nsSize& aSize) {SizeTo(aSize.width, aSize.height);}
void SizeBy(nscoord aDeltaWidth, nscoord aDeltaHeight) {width += aDeltaWidth;
height += aDeltaHeight;}
// Inflate the rect by the specified width/height or margin
void Inflate(nscoord aDx, nscoord aDy);
void Inflate(const nsSize& aSize) {Inflate(aSize.width, aSize.height);}
void Inflate(const nsMargin& aMargin);
// Deflate the rect by the specified width/height or margin
void Deflate(nscoord aDx, nscoord aDy);
void Deflate(const nsSize& aSize) {Deflate(aSize.width, aSize.height);}
void Deflate(const nsMargin& aMargin);
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator.
PRBool operator==(const nsRect& aRect) const {
return (PRBool) ((IsEmpty() && aRect.IsEmpty()) ||
((x == aRect.x) && (y == aRect.y) &&
(width == aRect.width) && (height == aRect.height)));
}
PRBool operator!=(const nsRect& aRect) const {
return (PRBool) !operator==(aRect);
}
nsRect operator+(const nsRect& aRect) const {
return nsRect(x + aRect.x, y + aRect.y,
width + aRect.width, height + aRect.height);
}
nsRect operator-(const nsRect& aRect) const {
return nsRect(x - aRect.x, y - aRect.y,
width - aRect.width, height - aRect.height);
}
nsRect& operator+=(const nsPoint& aPoint) {x += aPoint.x; y += aPoint.y; return *this;}
nsRect& operator-=(const nsPoint& aPoint) {x -= aPoint.x; y -= aPoint.y; return *this;}
nsRect& operator*=(const float aScale) {x = NSToCoordRound(x * aScale);
y = NSToCoordRound(y * aScale);
width = NSToCoordRound(width * aScale);
height = NSToCoordRound(height * aScale);
return *this;}
nsRect& ScaleRoundOut(const float aScale);
nsRect& ScaleRoundIn(const float aScale);
// Helper methods for computing the extents
nscoord XMost() const {return x + width;}
nscoord YMost() const {return y + height;}
};
// Diagnostics
extern NS_GFX FILE* operator<<(FILE* out, const nsRect& rect);
#endif /* NSRECT_H */

View File

@@ -1,299 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRenderingContextImpl_h___
#define nsRenderingContextImpl_h___
#include "nsIRenderingContext.h"
#include "nsPoint.h"
#include "nsSize.h"
typedef struct {
double x; // x coordinate of edge's intersection with current scanline */
double dx; // change in x with respect to y
int i; // edge number: edge i goes from mPointList[i] to mPointList[i+1]
} Edge;
class NS_GFX nsRenderingContextImpl : public nsIRenderingContext
{
// CLASS MEMBERS
public:
protected:
nsTransform2D *mTranMatrix; // The rendering contexts transformation matrix
nsLineStyle mLineStyle; // The current linestyle, currenly used on mac, other platfroms to follow
int mAct; // number of active edges
Edge *mActive; // active edge list:edges crossing scanline y
public:
nsRenderingContextImpl();
// CLASS METHODS
/**
* Gets the Pen Mode for the RenderingContext
* @param aPenMode The Pen Mode to be retrieved
* @return NS_OK if the Pen Mode is correctly retrieved
*/
NS_IMETHOD GetPenMode(nsPenMode &aPenMode) { return NS_ERROR_FAILURE;}
/**
* Sets the Pen Mode for the RenderingContext
* @param aPenMode The Pen Mode
* @return NS_OK if the Pen Mode is correctly set
*/
NS_IMETHOD SetPenMode(nsPenMode aPenMode) { return NS_ERROR_FAILURE;};
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
* @update 03/29/00 dwc
*/
NS_IMETHOD DrawPath(nsPathPoint aPointArray[],PRInt32 aNumPts);
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
* @update 03/29/00 dwc
*/
NS_IMETHOD FillPath(nsPathPoint aPointArray[],PRInt32 aNumPts);
/**
* Fill a poly in the current foreground color
* @param aPoints points to use for the drawing, last must equal first
* @param aNumPonts number of points in the polygon
*/
NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
* @update 05/01/00 dwc
*/
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) { return NS_OK;}
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
* @update 05/01/00 dwc
*/
NS_IMETHOD FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) { return NS_OK; }
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer);
NS_IMETHOD ReleaseBackbuffer(void);
NS_IMETHOD DestroyCachedBackbuffer(void);
#ifdef IBMBIDI
/**
* Let the device context know whether we want text reordered with
* right-to-left base direction
*/
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
#endif // IBMBIDI
#ifdef USE_IMG2
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect);
NS_IMETHOD DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect);
#endif
protected:
virtual ~nsRenderingContextImpl();
/** ---------------------------------------------------
* Check to see if the given size of tile can be imaged by the RenderingContext
* @update 03/29/00 dwc
* @param aWidth The width of the tile
* @param aHeight The height of the tile
* @return PR_TRUE the RenderingContext can handle this tile
*/
virtual PRBool CanTile(nscoord aWidth,nscoord aHeight) { return PR_FALSE; }
/** ---------------------------------------------------
* A bit blitter to tile images to the background recursively
* @update 3/29/00 dwc
* @param aDS -- Target drawing surface for the rendering context
* @param aSrcRect -- Rectangle we are build with the image
* @param aHeight -- height of the tile
* @param aWidth -- width of the tile
*/
void TileImage(nsDrawingSurface aDS,nsRect &aSrcRect,PRInt16 aWidth,PRInt16 aHeight);
void cdelete(int i);
void cinsert(int i,int y,const nsPoint aPointArray[],PRInt32 aNumPts);
/**
* Determine if a rect's width and height will fit within a specified width and height
* @param aRect rectangle to test
* @param aWidth width to determine if the rectangle's width will fit within
* @param aHeight height to determine if the rectangles height will fit within
* @returns PR_TRUE if the rect width and height fits with aWidth, aHeight, PR_FALSE
* otherwise.
*/
PRBool RectFitsInside(const nsRect& aRect, PRInt32 aWidth, PRInt32 aHeight) const;
/**
* Determine if two rectangles width and height will fit within a specified width and height
* @param aRect1 first rectangle to test
* @param aRect1 second rectangle to test
* @param aWidth width to determine if both rectangle's width will fit within
* @param aHeight height to determine if both rectangles height will fit within
* @returns PR_TRUE if the rect1's and rect2's width and height fits with aWidth,
* aHeight, PR_FALSE otherwise.
*/
PRBool BothRectsFitInside(const nsRect& aRect1, const nsRect& aRect2, PRInt32 aWidth, PRInt32 aHeight, nsRect& aNewSize) const;
/**
* Return an offscreen surface size from a set of discrete surface sizes.
* The smallest discrete surface size that can enclose both the Maximum widget
* size (@see GetMaxWidgetBounds) and the requested size is returned.
*
* @param aMaxBackbufferSize Maximum size that may be requested for the backbuffer
* @param aRequestedSize Requested size for the offscreen.
* @param aSurfaceSize contains the surface size
*/
void CalculateDiscreteSurfaceSize(const nsRect& aMaxBackbufferSize, const nsRect& aRequestedSize, nsRect& aSize);
/**
* Get the size of the offscreen drawing surface..
*
* @param aMaxBackbufferSize Maximum size that may be requested for the backbuffer
* @param aRequestedSize Desired size for the offscreen.
* @param aSurfaceSize Offscreen adjusted to a discrete size which encloses aRequestedSize.
*/
void GetDrawingSurfaceSize(const nsRect& aMaxBackbufferSize, const nsRect& aRequestedSize, nsRect& aSurfaceSize);
/**
* Utility method used to implement NS_IMETHOD GetBackbuffer
*
* @param aRequestedSize size of the backbuffer area requested
* @param aMaxSize maximum size that may be requested for the backbuffer
* @param aBackbuffer drawing surface used as the backbuffer
* @param aCacheBackbuffer PR_TRUE then the backbuffer will be cached, if PR_FALSE it is created each time
*/
nsresult AllocateBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer, PRBool aCacheBackbuffer);
public:
protected:
nsPenMode mPenMode;
private:
static nsDrawingSurface gBackbuffer; //singleton backbuffer
static nsRect gBackbufferBounds; //backbuffer bounds
// Largest requested offscreen size if larger than a full screen.
static nsSize gLargestRequestedSize;
};
/** ---------------------------------------------------
* Class QBezierCurve, a quadratic bezier curve
* @update 4/27/2000 dwc
*/
class QBezierCurve
{
public:
nsFloatPoint mAnc1;
nsFloatPoint mCon;
nsFloatPoint mAnc2;
QBezierCurve() {mAnc1.x=0;mAnc1.y=0;mCon=mAnc2=mAnc1;}
void SetControls(nsFloatPoint &aAnc1,nsFloatPoint &aCon,nsFloatPoint &aAnc2) { mAnc1 = aAnc1; mCon = aCon; mAnc2 = aAnc2;}
void SetPoints(nscoord a1x,nscoord a1y,nscoord acx,nscoord acy,nscoord a2x,nscoord a2y) {mAnc1.MoveTo(a1x,a1y),mCon.MoveTo(acx,acy),mAnc2.MoveTo(a2x,a2y);}
void SetPoints(float a1x,float a1y,float acx,float acy,float a2x,float a2y) {mAnc1.MoveTo(a1x,a1y),mCon.MoveTo(acx,acy),mAnc2.MoveTo(a2x,a2y);}
void DebugPrint();
/** ---------------------------------------------------
* Divide a Quadratic curve into line segments if it is not smaller than a certain size
* else it is so small that it can be approximated by 2 lineto calls
* @param aRenderingContext -- The RenderingContext to use to draw with
* @update 3/26/99 dwc
*/
void SubDivide(nsIRenderingContext *aRenderingContext);
/** ---------------------------------------------------
* Divide a Quadratic curve into line segments if it is not smaller than a certain size
* else it is so small that it can be approximated by 2 lineto calls
* @param nsPoint* -- The points array to rasterize into
* @param aNumPts* -- Current number of points in this array
* @update 3/26/99 dwc
*/
void SubDivide(nsPoint aThePoints[],PRInt16 *aNumPts);
/** ---------------------------------------------------
* Divide a Quadratic Bezier curve at the mid-point
* @update 3/26/99 dwc
* @param aCurve1 -- Curve 1 as a result of the division
* @param aCurve2 -- Curve 2 as a result of the division
*/
void MidPointDivide(QBezierCurve *A,QBezierCurve *B);
};
enum eSegType {eUNDEF,eLINE,eQCURVE,eCCURVE};
/** ---------------------------------------------------
* A class to iterate through a nsPathPoint array and return segments
* @update 04/27/00 dwc
*/
class nsPathIter {
public:
enum eSegType {eUNDEF,eLINE,eQCURVE,eCCURVE};
private:
PRUint32 mCurPoint;
PRUint32 mNumPoints;
nsPathPoint *mThePath;
public:
nsPathIter();
nsPathIter(nsPathPoint* aThePath,PRUint32 aNumPts);
PRBool NextSeg(QBezierCurve& TheSegment,eSegType& aCurveType);
};
#endif /* nsRenderingContextImpl */

View File

@@ -1,82 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRepeater_h___
#define nsRepeater_h___
#include "nscore.h"
class EventRecord;
class NS_WIDGET Repeater
{
public:
Repeater();
virtual ~Repeater();
virtual void RepeatAction(const EventRecord &aMacEvent) {}
virtual void IdleAction(const EventRecord &aMacEvent) {}
void StartRepeating();
void StopRepeating();
void StartIdling();
void StopIdling();
static void DoRepeaters(const EventRecord &aMacEvent);
static void DoIdlers(const EventRecord &aMacEvent);
protected:
void AddToRepeatList();
void RemoveFromRepeatList();
void AddToIdleList();
void RemoveFromIdleList();
static Repeater* sRepeaters;
static Repeater* sIdlers;
bool mRepeating;
bool mIdling;
Repeater* mPrevRptr;
Repeater* mNextRptr;
Repeater* mPrevIdlr;
Repeater* mNextIdlr;
};
#endif

View File

@@ -1,81 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NSSIZE_H
#define NSSIZE_H
#include "nsCoord.h"
// Maximum allowable size
#define NS_MAXSIZE nscoord(1 << 30)
struct nsSize {
nscoord width, height;
// Constructors
nsSize() {}
nsSize(const nsSize& aSize) {width = aSize.width; height = aSize.height;}
nsSize(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
void SizeTo(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
void SizeBy(nscoord aDeltaWidth, nscoord aDeltaHeight) {width += aDeltaWidth;
height += aDeltaHeight;}
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator
PRBool operator==(const nsSize& aSize) const {
return (PRBool) ((width == aSize.width) && (height == aSize.height));
}
PRBool operator!=(const nsSize& aSize) const {
return (PRBool) ((width != aSize.width) || (height != aSize.height));
}
nsSize operator+(const nsSize& aSize) const {
return nsSize(width + aSize.width, height + aSize.height);
}
nsSize operator-(const nsSize& aSize) const {
return nsSize(width - aSize.width, height - aSize.height);
}
nsSize& operator+=(const nsSize& aSize) {width += aSize.width;
height += aSize.height;
return *this;}
nsSize& operator-=(const nsSize& aSize) {width -= aSize.width;
height -= aSize.height;
return *this;}
};
#endif /* NSSIZE_H */

View File

@@ -1,167 +0,0 @@
// No appearance at all.
#define NS_THEME_NONE 0
// A typical dialog button.
#define NS_THEME_BUTTON 1
// A radio element within a radio group.
#define NS_THEME_RADIO 2
// A checkbox element.
#define NS_THEME_CHECKBOX 3
// The toolbox that contains the toolbars.
#define NS_THEME_TOOLBOX 11
// A toolbar in an application window.
#define NS_THEME_TOOLBAR 12
// A single toolbar button (with no associated dropdown)
#define NS_THEME_TOOLBAR_BUTTON 13
// A dual toolbar button (e.g., a Back button with a dropdown)
#define NS_THEME_TOOLBAR_DUAL_BUTTON 14
// The dropdown portion of a dual toolbar button
#define NS_THEME_TOOLBAR_DUAL_BUTTON_DROPDOWN 15
// A separator. Can be horizontal or vertical.
#define NS_THEME_TOOLBAR_SEPARATOR 16
// The gripper for a toolbar.
#define NS_THEME_TOOLBAR_GRIPPER 17
// A status bar in a main application window.
#define NS_THEME_STATUSBAR 21
// A single pane of a status bar.
#define NS_THEME_STATUSBAR_PANEL 22
// The resizer background area in a status bar
// for the resizer widget in the corner of a window.
#define NS_THEME_STATUSBAR_RESIZER_PANEL 23
// The resizer itself.
#define NS_THEME_RESIZER 24
// List boxes
#define NS_THEME_LISTBOX 31
// A listbox item
#define NS_THEME_LISTBOX_LISTITEM 32
// A tree widget
#define NS_THEME_TREEVIEW 41
// A tree item
#define NS_THEME_TREEVIEW_TREEITEM 42
// A tree widget twisty
#define NS_THEME_TREEVIEW_TWISTY 43
// A tree widget branch line
#define NS_THEME_TREEVIEW_LINE 44
// A listbox or tree widget header
#define NS_THEME_TREEVIEW_HEADER 45
// An individual header cell
#define NS_THEME_TREEVIEW_HEADER_CELL 46
// The sort arrow for a header.
#define NS_THEME_TREEVIEW_HEADER_SORTARROW 47
// A horizontal progress bar.
#define NS_THEME_PROGRESSBAR 51
// The progress bar's progress indicator
#define NS_THEME_PROGRESSBAR_CHUNK 52
// A vertical progress bar.
#define NS_THEME_PROGRESSBAR_VERTICAL 53
// A vertical progress chunk
#define NS_THEME_PROGRESSBAR_CHUNK_VERTICAL 54
// A single tab in a tab widget.
#define NS_THEME_TAB 61
// A single pane (inside the tabpanels container)
#define NS_THEME_TAB_PANEL 62
// The tab just before the selection
#define NS_THEME_TAB_LEFT_EDGE 63
// The tab just after the selection
#define NS_THEME_TAB_RIGHT_EDGE 64
// The tab panels container.
#define NS_THEME_TAB_PANELS 65
// A tooltip
#define NS_THEME_TOOLTIP 71
// A spin control (up/down control for time/date pickers)
#define NS_THEME_SPINNER 72
// The up button of a spin control
#define NS_THEME_SPINNER_UP_BUTTON 73
// The down button of a spin control
#define NS_THEME_SPINNER_DOWN_BUTTON 74
// A scrollbar.
#define NS_THEME_SCROLLBAR 81
// A scrollbar button (up/down/left/right)
#define NS_THEME_SCROLLBAR_BUTTON_UP 82
#define NS_THEME_SCROLLBAR_BUTTON_DOWN 83
#define NS_THEME_SCROLLBAR_BUTTON_LEFT 84
#define NS_THEME_SCROLLBAR_BUTTON_RIGHT 85
// The scrollbar track
#define NS_THEME_SCROLLBAR_TRACK_HORIZONTAL 86
#define NS_THEME_SCROLLBAR_TRACK_VERTICAL 87
// The scrollbar thumb
#define NS_THEME_SCROLLBAR_THUMB_HORIZONTAL 88
#define NS_THEME_SCROLLBAR_THUMB_VERTICAL 89
// The gripper that goes on the thumb
#define NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL 90
#define NS_THEME_SCROLLBAR_GRIPPER_VERTICAL 91
// A textfield or text area
#define NS_THEME_TEXTFIELD 95
// The caret of a text area
#define NS_THEME_TEXTFIELD_CARET 96
// A dropdown list.
#define NS_THEME_DROPDOWN 101
// The dropdown button(s) that open up a dropdown list.
#define NS_THEME_DROPDOWN_BUTTON 102
// The text part of a dropdown list, to left of button
#define NS_THEME_DROPDOWN_TEXT 103
// A slider
#define NS_THEME_SLIDER 111
// A slider's thumb
#define NS_THEME_SLIDER_THUMB 112
// If the platform supports it, the left/right chunks
// of the slider thumb
#define NS_THEME_SLIDER_THUMB_START 113
#define NS_THEME_SLIDER_THUMB_END 114
// The ticks for a slider.
#define NS_THEME_SLIDER_TICK 115
// A generic container that always repaints on state
// changes. This is a hack to make checkboxes and
// radio buttons work.
#define NS_THEME_CHECKBOX_CONTAINER 200
#define NS_THEME_RADIO_CONTAINER 201

View File

@@ -1,256 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTransform2D_h___
#define nsTransform2D_h___
#include "nscore.h"
#include "nsCoord.h"
#include "nsUnitConversion.h"
#define MG_2DIDENTITY 0
#define MG_2DTRANSLATION 1
#define MG_2DSCALE 2
#define MG_2DGENERAL 4
class NS_GFX nsTransform2D
{
private:
//accelerators
float m00, m01, m10, m11, m20, m21;
PRUint16 type;
public:
//constructors
nsTransform2D(void) { SetToIdentity(); }
nsTransform2D(nsTransform2D *aTransform2D) { SetMatrix(aTransform2D); }
//destructor
~nsTransform2D(void) { }
/**
* get the type of this transform
*
* @param
* @return type from above set
* @exception
* @author michaelp 09-25-97 1:56pm
**/
PRUint16 GetType(void) { return type; }
/**
* set this transform to identity
*
* @param
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void SetToIdentity(void) { m01 = m10 = m20 = m21 = 0.0f; m00 = m11 = 1.0f; type = MG_2DIDENTITY; }
/**
* set this transform to a scale
*
* @param sx, x scale
* @param sy, y scale
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void SetToScale(float sx, float sy);
/**
* set this transform to a translation
*
* @param tx, x translation
* @param ty, y translation
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void SetToTranslate(float tx, float ty);
/**
* get the translation portion of this transform
*
* @param pt, Point to return translation values in
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void GetTranslation(float *ptX, float *ptY) { *ptX = m20; *ptY = m21; }
void GetTranslationCoord(nscoord *ptX, nscoord *ptY) { *ptX = NSToCoordRound(m20); *ptY = NSToCoordRound(m21); }
/**
* set the translation portion of this transform
*
* @param tx, x translation
* @param ty, y translation
* @exception
**/
void SetTranslation(float tX, float tY) {
m20 = tX;
m21 = tY;
type |= MG_2DTRANSLATION;
}
/**
* get the X translation portion of this transform
*
* @param
* @returns x component of translation
* @exception
**/
float GetXTranslation(void) { return m20; }
nscoord GetXTranslationCoord(void) { return NSToCoordRound(m20); }
/**
* get the Y translation portion of this transform
*
* @param
* @returns y component of translation
* @exception
**/
float GetYTranslation(void) { return m21; }
nscoord GetYTranslationCoord(void) { return NSToCoordRound(m21); }
/**
* set this matrix and type from another Transform2D
*
* @param aTransform2D is the Transform2D to be copied from
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void SetMatrix(nsTransform2D *aTransform2D);
/**
* post-multiply a new Transform
*
* @param newxform new Transform2D
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void Concatenate(nsTransform2D *newxform);
/**
* pre-multiply a new Transform
*
* @param newxform new Transform2D
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void PreConcatenate(nsTransform2D *newxform);
/**
* apply nontranslation portion of matrix to vector
*
* @param pt Point to transform
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void TransformNoXLate(float *ptX, float *ptY);
void TransformNoXLateCoord(nscoord *ptX, nscoord *ptY);
/**
* apply matrix to vector
*
* @param pt Point to transform
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void Transform(float *ptX, float *ptY);
void TransformCoord(nscoord *ptX, nscoord *ptY);
/**
* apply matrix to rect
*
* @param rect Rect to transform
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void Transform(float *aX, float *aY, float *aWidth, float *aHeight);
void TransformCoord(nscoord *aX, nscoord *aY, nscoord *aWidth, nscoord *aHeight);
/**
* Scale an array of X/Y coordinates by the X/Y scale factor in the
* matrix. The scale is done as if the other coordinate were zero.
*
* @param aSrc Base of coordinate input array
* @param aDst Base of coordinate output array
* @param aNumCoords Number of coordinates to scale
*/
void ScaleXCoords(const nscoord* aSrc, PRUint32 aNumCoords, PRIntn* aDst);
void ScaleYCoords(const nscoord* aSrc, PRUint32 aNumCoords, PRIntn* aDst);
/**
* add a translation to a Transform via x, y pair
*
* @param ptX x value to add as x translation
* @param ptY y value to add as y translation
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void AddTranslation(float ptX, float ptY);
/**
* add a scale to a Transform via x, y pair
*
* @param ptX x value to add as x scale
* @param ptY y value to add as y scale
* @exception
* @author michaelp 09-25-97 1:56pm
**/
void AddScale(float ptX, float ptY);
};
#endif

View File

@@ -1,2 +0,0 @@
icon_0.gif
icon_1.gif

View File

@@ -1,139 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx
EXPORTS = nsFontList.h
LIBRARY_NAME = gkgfx
EXPORT_LIBRARY = 1
REQUIRES = xpcom \
string \
widget \
locale \
view \
pref \
gfx2 \
imglib2 \
uconv \
unicharutil \
$(NULL)
ifneq (,$(filter os2 windows,$(MOZ_WIDGET_TOOLKIT)))
DIRS =
else
DIRS = ps
endif
ifneq (,$(filter beos os2 mac windows,$(MOZ_GFX_TOOLKIT)))
DIRS += $(MOZ_GFX_TOOLKIT)
endif
# Build xlibrgb only for X toolkits and/or Xprint
ifneq (,$(filter xlib,$(MOZ_WIDGET_TOOLKIT))$(MOZ_ENABLE_XLIB)$(MOZ_ENABLE_XPRINT))
DIRS += xlibrgb
endif
ifdef MOZ_ENABLE_GTK
DIRS += gtk
endif
ifdef MOZ_ENABLE_GTK2
DIRS += gtk2
endif
ifdef MOZ_ENABLE_QT
DIRS += qt
endif
ifdef MOZ_ENABLE_XLIB
DIRS += xlib
endif
ifdef MOZ_ENABLE_PHOTON
DIRS += photon
endif
ifdef MOZ_ENABLE_XPRINT
DIRS += xprint
endif
CPPSRCS = \
nsBlender.cpp \
nsColor.cpp \
nsColorNames.cpp \
nsDeviceContext.cpp \
nsFont.cpp \
nsFontList.cpp \
nsRenderingContextImpl.cpp \
nsRect.cpp \
nsTransform2D.cpp \
nsScriptableRegion.cpp \
nsGraphicsImpl.cpp \
nsPrintOptionsImpl.cpp \
nsPrintSettingsImpl.cpp \
$(NULL)
ifeq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
CPPSRCS += nsCompressedCharMap.cpp
endif
ifneq (,$(filter gtk xlib os2,$(MOZ_WIDGET_TOOLKIT)))
CPPSRCS += \
nsRegion.cpp \
nsRegionImpl.cpp \
$(NULL)
endif
ifneq (,$(filter gtk xlib beos,$(MOZ_WIDGET_TOOLKIT)))
CPPSRCS += imgScaler.cpp
endif
ifeq (mac, $(MOZ_WIDGET_TOOLKIT))
CPPSRCS += \
mac/nsRegionPool.cpp \
$(NULL)
endif
EXTRA_DSO_LDOPTS = \
$(DIST)/lib/$(LIB_PREFIX)mozutil_s.$(LIB_SUFFIX) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
ifeq (mac, $(MOZ_WIDGET_TOOLKIT))
EXTRA_DSO_LDOPTS += \
$(TK_LIBS) \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_GFX
ifeq ($(OS_ARCH),WINNT)
DEFINES += -DWIN32_LEAN_AND_MEAN
endif
libs:: icon_0.gif icon_1.gif
$(INSTALL) -m 555 $^ $(DIST)/bin/res/gfx

View File

@@ -1,78 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx
LIBRARY_NAME = gfx_beos
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsGfxBeOSModule
CPPSRCS = \
nsDeviceContextBeOS.cpp \
nsDeviceContextSpecFactoryB.cpp \
nsDeviceContextSpecB.cpp \
nsDrawingSurfaceBeOS.cpp \
nsFontMetricsBeOS.cpp \
nsGfxFactoryBeOS.cpp \
nsGraphicsStateBeOS.cpp \
nsRenderingContextBeOS.cpp \
nsImageBeOS.cpp \
nsRegionBeOS.cpp \
nsScreenBeOS.cpp \
nsScreenManagerBeOS.cpp \
nsPrintOptionsBeOS.cpp \
$(NULL)
REQUIRES = xpcom \
string \
pref \
widget \
view \
intl \
uconv \
dom \
windowwatcher \
unicharutil \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_GFXONXP
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS)
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) $(MOZ_JS_LIBS) \
-lgkgfx \
$(XPCOM_LIBS) \
$(TK_LIBS) \
$(NSPR_LIBS)
INCLUDES += \
-I$(srcdir)/. \
-I$(srcdir)/.. \
$(NULL)

View File

@@ -1,472 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <math.h>
#include "nspr.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsCRT.h"
#include "nsReadableUtils.h"
#include "nsDeviceContextBeOS.h"
#include "nsFontMetricsBeOS.h"
#include "nsGfxCIID.h"
#include "nsGfxPSCID.h"
#include "nsIDeviceContextPS.h"
#include <ScrollBar.h>
#include <Screen.h>
#include "nsIScreenManager.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
nscoord nsDeviceContextBeOS::mDpi = 96;
nsDeviceContextBeOS::nsDeviceContextBeOS()
: DeviceContextImpl()
{
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mDepth = 0 ;
mNumCells = 0;
mWidthFloat = 0.0f;
mHeightFloat = 0.0f;
mWidth = -1;
mHeight = -1;
}
nsDeviceContextBeOS::~nsDeviceContextBeOS()
{
nsresult rv;
nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv);
if (NS_SUCCEEDED(rv)) {
prefs->UnregisterCallback("browser.display.screen_resolution",
prefChanged, (void *)this);
}
}
NS_IMETHODIMP nsDeviceContextBeOS::Init(nsNativeWidget aNativeWidget)
{
// get the screen object and its width/height
// XXXRight now this will only get the primary monitor.
nsresult ignore;
nsCOMPtr<nsIScreenManager> sm ( do_GetService("@mozilla.org/gfx/screenmanager;1", &ignore) );
if ( sm ) {
nsCOMPtr<nsIScreen> screen;
sm->GetPrimaryScreen ( getter_AddRefs(screen) );
if ( screen ) {
PRInt32 x, y, width, height, depth;
screen->GetAvailRect ( &x, &y, &width, &height );
screen->GetPixelDepth ( &depth );
mWidthFloat = float(width);
mHeightFloat = float(height);
mDepth = NS_STATIC_CAST ( PRUint32, depth );
}
}
static int initialized = 0;
if (!initialized) {
initialized = 1;
// Set prefVal the value of the preference "browser.display.screen_resolution"
// 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
PRInt32 prefVal = -1;
nsresult res;
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &res));
if (NS_SUCCEEDED(res) && prefs) {
res = prefs->GetIntPref("browser.display.screen_resolution", &prefVal);
if (! NS_SUCCEEDED(res)) {
prefVal = -1;
}
prefs->RegisterCallback("browser.display.screen_resolution", prefChanged,
(void *)this);
}
// Set OSVal to what the operating system thinks the logical resolution is.
PRInt32 OSVal = 72;
if (prefVal > 0) {
// If there's a valid pref value for the logical resolution,
// use it.
mDpi = prefVal;
} else if ((prefVal == 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;
}
}
SetDPI(mDpi);
mScrollbarHeight = PRInt16(B_H_SCROLL_BAR_HEIGHT);
mScrollbarWidth = PRInt16(B_V_SCROLL_BAR_WIDTH);
#ifdef DEBUG
static PRBool once = PR_TRUE;
if (once) {
printf("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n", mDpi, mTwipsToPixels, mPixelsToTwips,mDepth);
once = PR_FALSE;
}
#endif
DeviceContextImpl::CommonInit();
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceBeOS *surf;
BView *w;
w = (BView*)mWidget;
// to call init for this, we need to have a valid nsDrawingSurfaceBeOS created
pContext = new nsRenderingContextBeOS();
if (nsnull != pContext)
{
NS_ADDREF(pContext);
// create the nsDrawingSurfaceBeOS
surf = new nsDrawingSurfaceBeOS();
if (surf && w)
{
// init the nsDrawingSurfaceBeOS
rv = surf->Init(w);
if (NS_OK == rv)
// Init the nsRenderingContextBeOS
rv = pContext->Init(this, surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv)
{
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
NS_IMETHODIMP nsDeviceContextBeOS::SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
//XXX it is very critical that this not lie!! MMP
// read the comments in the mac code for this
aSupportsWidgets = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
aWidth = mScrollbarWidth * mPixelsToTwips;
aHeight = mScrollbarHeight * mPixelsToTwips;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
{
nsresult status = NS_OK;
switch (aID) {
case eSystemFont_Caption: // css2
case eSystemFont_Icon :
case eSystemFont_Menu :
case eSystemFont_MessageBox :
case eSystemFont_SmallCaption :
case eSystemFont_StatusBar :
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:
case eSystemFont_Tooltips: // moz
case eSystemFont_Widget:
status = GetSystemFontInfo(be_plain_font, aID, aFont);
break;
}
return status;
}
NS_IMETHODIMP nsDeviceContextBeOS::GetDrawingSurface(nsIRenderingContext &aContext,
nsDrawingSurface &aSurface)
{
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::ConvertPixel(nscolor aColor,
PRUint32 & aPixel)
{
// koehler@mythrium.com:
// I think this fill the 32 bits pixel with the desired color
// It's possible that the nscolor is not representing that color
// if you just dump it inside a 32 bits value.
aPixel = aColor;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::CheckFontExistence(const nsString& aFontName)
{
return nsFontMetricsBeOS::FamilyExists(aFontName);
}
/*
NS_IMETHODIMP nsDeviceContextBeOS::CheckFontExistence(const nsString& aFontName)
{
PRBool isthere = PR_FALSE;
char* cStr = ToNewCString(aFontName);
int32 numFamilies = count_font_families();
for(int32 i = 0; i < numFamilies; i++)
{
font_family family;
uint32 flags;
if(get_font_family(i, &family, &flags) == B_OK)
{
if(strcmp(family, cStr) == 0)
{
isthere = PR_TRUE;
break;
}
}
}
//printf("%s there? %s\n", cStr, isthere?"Yes":"No" );
delete[] cStr;
if (PR_TRUE == isthere)
return NS_OK;
else
return NS_ERROR_FAILURE;
}
*/
NS_IMETHODIMP nsDeviceContextBeOS::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
{
if (mWidth == -1)
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
if (mHeight == -1)
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
aWidth = mWidth;
aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::GetRect(nsRect &aRect)
{
PRInt32 width, height;
nsresult rv;
rv = GetDeviceSurfaceDimensions(width, height);
aRect.x = 0;
aRect.y = 0;
aRect.width = width;
aRect.height = height;
return rv;
}
NS_IMETHODIMP nsDeviceContextBeOS::GetClientRect(nsRect &aRect)
{
//XXX do we know if the client rect should ever differ from the screen rect?
return GetRect ( aRect );
}
NS_IMETHODIMP nsDeviceContextBeOS::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
// Create a Postscript device context
nsresult rv;
nsIDeviceContextPS *dcps;
rv = nsComponentManager::CreateInstance(kCDeviceContextPS,
nsnull,
NS_GET_IID(nsIDeviceContextPS),
(void **)&dcps);
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context");
dcps->SetSpec(aDevice);
dcps->InitDeviceContextPS((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
NS_RELEASE(dcps);
return rv;
}
NS_IMETHODIMP nsDeviceContextBeOS::BeginDocument(PRUnichar * aTitle)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::EndDocument(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::BeginPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::EndPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextBeOS::GetDepth(PRUint32& aDepth)
{
aDepth = mDepth;
return NS_OK;
}
nsresult
nsDeviceContextBeOS::SetDPI(PRInt32 aDpi)
{
mDpi = aDpi;
int pt2t = 72;
// make p2t a nice round number - this prevents rounding problems
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(pt2t)) / float(aDpi)));
mTwipsToPixels = 1.0f / mPixelsToTwips;
// XXX need to reflow all documents
return NS_OK;
}
int nsDeviceContextBeOS::prefChanged(const char *aPref, void *aClosure)
{
nsDeviceContextBeOS *context = (nsDeviceContextBeOS*)aClosure;
nsresult rv;
if (nsCRT::strcmp(aPref, "browser.display.screen_resolution")==0) {
PRInt32 dpi;
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &rv));
rv = prefs->GetIntPref(aPref, &dpi);
if (NS_SUCCEEDED(rv))
context->SetDPI(dpi);
}
return 0;
}
nsresult
nsDeviceContextBeOS::GetSystemFontInfo(const BFont *theFont, nsSystemFontID anID, nsFont* aFont) const
{
nsresult status = NS_OK;
aFont->style = NS_FONT_STYLE_NORMAL;
aFont->weight = NS_FONT_WEIGHT_NORMAL;
aFont->decorations = NS_FONT_DECORATION_NONE;
// do we have the default_font defined by BeOS, if not then
// we error out.
if( !theFont )
theFont = be_plain_font; // BeOS default font
if( !theFont )
{
status = NS_ERROR_FAILURE;
}
else
{
font_family family;
font_style style;
font_height height;
theFont->GetFamilyAndStyle(&family, &style);
aFont->name.AssignWithConversion( family );
// No weight
theFont->GetHeight(&height);
aFont->size = NSIntPixelsToTwips(uint32(height.ascent+height.descent+height.leading), mPixelsToTwips);
// no style
// no decoration
status = NS_OK;
}
return (status);
}

View File

@@ -1,112 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextBeOS_h___
#define nsDeviceContextBeOS_h___
#include "nsDeviceContext.h"
#include "nsUnitConversion.h"
#include "nsIWidget.h"
#include "nsIView.h"
#include "nsIRenderingContext.h"
#include "nsRenderingContextBeOS.h"
class nsDeviceContextBeOS : public DeviceContextImpl
{
public:
nsDeviceContextBeOS();
virtual ~nsDeviceContextBeOS();
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aView,aContext));}
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aWidget,aContext));}
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
//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
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetClientRect(nsRect &aRect);
NS_IMETHOD GetRect(nsRect &aRect);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
NS_IMETHOD GetDepth(PRUint32& aDepth);
static int prefChanged(const char *aPref, void *aClosure);
nsresult SetDPI(PRInt32 dpi);
private:
PRUint32 mDepth;
PRBool mWriteable;
PRUint32 mNumCells;
PRInt16 mScrollbarHeight;
PRInt16 mScrollbarWidth;
static nscoord mDpi;
float mWidthFloat;
float mHeightFloat;
PRInt32 mWidth;
PRInt32 mHeight;
nsresult GetSystemFontInfo(const BFont *font, nsSystemFontID anID, nsFont* aFont) const;
};
#endif /* nsDeviceContextBeOS_h___ */

View File

@@ -1,638 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecB.h"
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
#include "nsIDOMWindow.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsReadableUtils.h"
#include "nsISupportsArray.h"
//#include "prmem.h"
//#include "plstr.h"
//----------------------------------------------------------------------------------
// The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecG
// The PrinterEnumerator creates the printer info
// but the nsDeviceContextSpecG cleans it up
// If it gets created (via the Page Setup Dialog) but the user never prints anything
// then it will never be delete, so this class takes care of that.
class GlobalPrinters {
public:
static GlobalPrinters* GetInstance() { return &mGlobalPrinters; }
~GlobalPrinters() { FreeGlobalPrinters(); }
void FreeGlobalPrinters();
nsresult InitializeGlobalPrinters();
PRBool PrintersAreAllocated() { return mGlobalPrinterList != nsnull; }
PRInt32 GetNumPrinters() { return mGlobalNumPrinters; }
nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
protected:
GlobalPrinters() {}
static GlobalPrinters mGlobalPrinters;
static nsStringArray* mGlobalPrinterList;
static int mGlobalNumPrinters;
};
//---------------
// static members
GlobalPrinters GlobalPrinters::mGlobalPrinters;
nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
int GlobalPrinters::mGlobalNumPrinters = 0;
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecBeOS
* @update dc 12/02/98
*/
nsDeviceContextSpecBeOS :: nsDeviceContextSpecBeOS()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
* Destroy the nsDeviceContextSpecBeOS
* @update dc 2/15/98
*/
nsDeviceContextSpecBeOS :: ~nsDeviceContextSpecBeOS()
{
}
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
#if 0
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecBeOS, nsIDeviceContextSpec)
#endif
NS_IMETHODIMP nsDeviceContextSpecBeOS :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDeviceContextSpecIID))
{
nsIDeviceContextSpec* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDeviceContextSpecPSIID))
{
nsIDeviceContextSpecPS* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDeviceContextSpec* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDeviceContextSpecBeOS)
NS_IMPL_RELEASE(nsDeviceContextSpecBeOS)
/** -------------------------------------------------------
*/
static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
const char* aChromeURL,
PRBool& aClickedOK)
{
NS_ASSERTION(aPS, "Must have a print settings!");
aClickedOK = PR_FALSE;
nsresult rv = NS_ERROR_FAILURE;
// create a nsISupportsArray of the parameters
// being passed to the window
nsCOMPtr<nsISupportsArray> array;
NS_NewISupportsArray(getter_AddRefs(array));
if (!array) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintSettings> ps = aPS;
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
array->AppendElement(psSupports);
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
array->AppendElement(blkSupps);
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
NS_ASSERTION(array, "array must be a supports");
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
nsCOMPtr<nsIDOMWindow> newWindow;
rv = wwatch->OpenWindow(parent, aChromeURL,
"_blank", "chrome,modal,centerscreen", array,
getter_AddRefs(newWindow));
}
}
if (NS_SUCCEEDED(rv)) {
PRInt32 buttonPressed = 0;
ioParamBlock->GetInt(0, &buttonPressed);
if (buttonPressed == 1) {
aClickedOK = PR_TRUE;
} else {
rv = NS_ERROR_ABORT;
}
} else {
rv = NS_ERROR_ABORT;
}
return rv;
}
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecBeOS
* @update dc 2/15/98
* @update syd 3/2/99
*/
NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS, PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
NS_ASSERTION(nsnull != aPS, "No print settings.");
// if there is a current selection then enable the "Selection" radio button
if (aPS != nsnull) {
PRBool isOn;
aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
}
}
char *path;
PRBool canPrint = PR_FALSE;
PRBool reversed = PR_FALSE;
PRBool color = PR_FALSE;
PRBool tofile = PR_FALSE;
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
PRInt32 paper_size = NS_LETTER_SIZE;
PRInt32 orientation = NS_PORTRAIT;
PRInt32 fromPage = 1;
PRInt32 toPage = 1;
PRUnichar *command = nsnull;
PRInt32 copies = 1;
PRUnichar *printer = nsnull;
PRUnichar *printfile = nsnull;
double dleft = 0.5;
double dright = 0.5;
double dtop = 0.5;
double dbottom = 0.5;
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
if (!aQuiet ) {
rv = DisplayXPDialog(aPS,
"chrome://global/content/printdialog.xul", canPrint);
}
else {
canPrint = PR_TRUE;
}
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
if (canPrint) {
if (aPS != nsnull) {
aPS->GetPrinterName(&printer);
aPS->GetPrintReversed(&reversed);
aPS->GetPrintInColor(&color);
aPS->GetPaperSize(&paper_size);
aPS->GetOrientation(&orientation);
aPS->GetPrintCommand(&command);
aPS->GetPrintRange(&printRange);
aPS->GetToFileName(&printfile);
aPS->GetPrintToFile(&tofile);
aPS->GetStartPageRange(&fromPage);
aPS->GetEndPageRange(&toPage);
aPS->GetNumCopies(&copies);
aPS->GetMarginTop(&dtop);
aPS->GetMarginLeft(&dleft);
aPS->GetMarginBottom(&dbottom);
aPS->GetMarginRight(&dright);
if (command != nsnull && printfile != nsnull) {
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
}
if (printer != nsnull)
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
#ifdef DEBUG_rods
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
printf("printRange %d\n", printRange);
printf("fromPage %d\n", fromPage);
printf("toPage %d\n", toPage);
#endif /* DEBUG_rods */
} else {
#ifdef VMS
// Note to whoever puts the "lpr" into the prefs file. Please contact me
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
strcpy(mPrData.command, "print");
#else
strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}");
#endif /* VMS */
}
mPrData.top = dtop;
mPrData.bottom = dbottom;
mPrData.left = dleft;
mPrData.right = dright;
mPrData.fpf = !reversed;
mPrData.grayscale = !color;
mPrData.size = paper_size;
mPrData.orientation = orientation;
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
// PWD, HOME, or fail
if (!printfile) {
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
strcpy(mPrData.path, "mozilla.ps");
if ( path != (char *) nsnull )
sprintf(mPrData.path, "%s/mozilla.ps", path);
else
return NS_ERROR_FAILURE;
}
#ifdef NOT_IMPLEMENTED_YET
if (mGlobalNumPrinters) {
for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) {
if (!(mGlobalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1)))
mQueue = PrnDlg.SetPrinterQueue(i);
}
}
#endif /* NOT_IMPLEMENTED_YET */
if (command != nsnull) {
nsMemory::Free(command);
}
if (printfile != nsnull) {
nsMemory::Free(printfile);
}
return NS_OK;
}
return rv;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetToPrinter( PRBool &aToPrinter )
{
aToPrinter = mPrData.toPrinter;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS::GetPrinterName ( char **aPrinter )
{
*aPrinter = &mPrData.printer[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS::GetCopies ( int &aCopies )
{
aCopies = mPrData.copies;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetFirstPageFirst ( PRBool &aFpf )
{
aFpf = mPrData.fpf;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetGrayscale ( PRBool &aGrayscale )
{
aGrayscale = mPrData.grayscale;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetSize ( int &aSize )
{
aSize = mPrData.size;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetPageDimensions ( float &aWidth, float &aHeight )
{
if ( mPrData.size == NS_LETTER_SIZE ) {
aWidth = 8.5;
aHeight = 11.0;
} else if ( mPrData.size == NS_LEGAL_SIZE ) {
aWidth = 8.5;
aHeight = 14.0;
} else if ( mPrData.size == NS_EXECUTIVE_SIZE ) {
aWidth = 7.5;
aHeight = 10.0;
} else if ( mPrData.size == NS_A4_SIZE ) {
// 210mm X 297mm == 8.27in X 11.69in
aWidth = 8.27;
aHeight = 11.69;
} else if ( mPrData.size == NS_A3_SIZE ) {
// 297mm X 420mm == 11.69in X 16.53in
aWidth = 11.69;
aHeight = 16.53;
}
if (mPrData.orientation == NS_LANDSCAPE) {
float temp;
temp = aWidth;
aWidth = aHeight;
aHeight = temp;
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetLandscape ( PRBool &landscape )
{
landscape = (mPrData.orientation == NS_LANDSCAPE);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetTopMargin ( float &value )
{
value = mPrData.top;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetBottomMargin ( float &value )
{
value = mPrData.bottom;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetRightMargin ( float &value )
{
value = mPrData.right;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetLeftMargin ( float &value )
{
value = mPrData.left;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetCommand ( char **aCommand )
{
*aCommand = &mPrData.command[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetPath ( char **aPath )
{
*aPath = &mPrData.path[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetUserCancelled( PRBool &aCancel )
{
aCancel = mPrData.cancel;
return NS_OK;
}
/** -------------------------------------------------------
* Closes the printmanager if it is open.
* @update dc 2/15/98
*/
NS_IMETHODIMP nsDeviceContextSpecBeOS :: ClosePrintManager()
{
return NS_OK;
}
// Printer Enumerator
nsPrinterEnumeratorBeOS::nsPrinterEnumeratorBeOS()
{
NS_INIT_REFCNT();
}
NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorBeOS, nsIPrinterEnumerator)
NS_IMETHODIMP nsPrinterEnumeratorBeOS::EnumeratePrintersExtended(PRUint32* aCount, PRUnichar*** aResult)
{
NS_ENSURE_ARG(aCount);
NS_ENSURE_ARG_POINTER(aResult);
*aCount = 0;
*aResult = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsPrinterEnumeratorBeOS::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
{
NS_ENSURE_ARG(aCount);
NS_ENSURE_ARG_POINTER(aResult);
if (aCount)
*aCount = 0;
else
return NS_ERROR_NULL_POINTER;
if (aResult)
*aResult = nsnull;
else
return NS_ERROR_NULL_POINTER;
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*));
if (!array && numPrinters > 0) {
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_OUT_OF_MEMORY;
}
int count = 0;
while( count < numPrinters )
{
PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count));
if (!str) {
for (int i = count - 1; i >= 0; i--)
nsMemory::Free(array[i]);
nsMemory::Free(array);
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_OUT_OF_MEMORY;
}
array[count++] = str;
}
*aCount = count;
*aResult = array;
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_OK;
}
NS_IMETHODIMP nsPrinterEnumeratorBeOS::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
{
/* fixme: We simply ignore the |aPrinter| argument here
* We should get the supported printer attributes from the printer and
* populate the print job options dialog with these data instead of using
* the "default set" here.
* However, this requires changes on all platforms and is another big chunk
* of patches ... ;-(
*/
PRBool pressedOK;
return DisplayXPDialog(aPrintSettings,
"chrome://global/content/printjoboptions.xul",
pressedOK);
}
//----------------------------------------------------------------------
nsresult GlobalPrinters::InitializeGlobalPrinters ()
{
if (PrintersAreAllocated()) {
return NS_OK;
}
mGlobalNumPrinters = 0;
mGlobalPrinterList = new nsStringArray();
if (!mGlobalPrinterList)
return NS_ERROR_OUT_OF_MEMORY;
/* add an entry for the default printer (see nsPostScriptObj.cpp) */
mGlobalPrinterList->AppendString(
nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME "default")));
mGlobalNumPrinters++;
/* get the list of printers */
char *printerList = nsnull;
/* the env var MOZILLA_PRINTER_LIST can "override" the prefs */
printerList = PR_GetEnv("MOZILLA_PRINTER_LIST");
if (!printerList) {
nsresult rv;
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
(void) pPrefs->CopyCharPref("print.printer_list", &printerList);
}
}
if (printerList) {
char *tok_lasts;
char *name;
/* PL_strtok_r() will modify the string - copy it! */
printerList = strdup(printerList);
if (!printerList)
return NS_ERROR_OUT_OF_MEMORY;
for( name = PL_strtok_r(printerList, " ", &tok_lasts) ;
name != nsnull ;
name = PL_strtok_r(nsnull, " ", &tok_lasts) )
{
mGlobalPrinterList->AppendString(
nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME)) +
nsString(NS_ConvertASCIItoUCS2(name)));
mGlobalNumPrinters++;
}
free(printerList);
}
if (mGlobalNumPrinters == 0)
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
return NS_OK;
}
//----------------------------------------------------------------------
void GlobalPrinters::FreeGlobalPrinters()
{
delete mGlobalPrinterList;
mGlobalPrinterList = nsnull;
mGlobalNumPrinters = 0;
}

View File

@@ -1,143 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecB_h___
#define nsDeviceContextSpecB_h___
#include "nsIDeviceContextSpec.h"
#include "nsDeviceContextSpecB.h"
#include "nsVoidArray.h"
#include "nsIDeviceContextSpecPS.h"
#include "nsIPrintSettings.h"
#include "nsIPrintOptions.h"
#include "nsPrintdBeOS.h"
class nsDeviceContextSpecBeOS : public nsIDeviceContextSpec ,
public nsIDeviceContextSpecPS
{
public:
/**
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
* @update dc 12/02/98
*/
nsDeviceContextSpecBeOS();
NS_DECL_ISUPPORTS
/**
* Initialize the nsDeviceContextSpecBeOS for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
/**
* Closes the printmanager if it is open.
* @update dc 2/13/98
* @return error status
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
NS_IMETHOD GetPrinterName ( char **aPrinter );
NS_IMETHOD GetCopies ( int &aCopies );
NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf );
NS_IMETHOD GetGrayscale( PRBool &aGrayscale );
NS_IMETHOD GetSize ( int &aSize );
NS_IMETHOD GetTopMargin ( float &value );
NS_IMETHOD GetBottomMargin ( float &value );
NS_IMETHOD GetLeftMargin ( float &value );
NS_IMETHOD GetRightMargin ( float &value );
NS_IMETHOD GetCommand ( char **aCommand );
NS_IMETHOD GetPath ( char **aPath );
NS_IMETHOD GetPageDimensions (float &aWidth, float &aHeight );
NS_IMETHOD GetLandscape (PRBool &aLandscape);
NS_IMETHOD GetUserCancelled( PRBool &aCancel );
/**
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
* @update dc 2/16/98
*/
protected:
virtual ~nsDeviceContextSpecBeOS();
public:
int InitializeGlobalPrinters();
void FreeGlobalPrinters();
protected:
BeOSPrData mPrData;
};
//-------------------------------------------------------------------------
// Printer Enumerator
//-------------------------------------------------------------------------
class nsPrinterEnumeratorBeOS : public nsIPrinterEnumerator
{
public:
nsPrinterEnumeratorBeOS();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTERENUMERATOR
protected:
};
#endif

View File

@@ -1,100 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecFactoryB.h"
#include "nsDeviceContextSpecB.h"
#include "nsGfxCIID.h"
#include "plstr.h"
/** -------------------------------------------------------
* Constructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryBeOS :: nsDeviceContextSpecFactoryBeOS()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
* Destructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryBeOS :: ~nsDeviceContextSpecFactoryBeOS()
{
}
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryBeOS, nsIDeviceContextSpecFactory)
/** -------------------------------------------------------
* Initialize the device context spec factory
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: Init(void)
{
return NS_OK;
}
/** -------------------------------------------------------
* Get a device context specification
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv))
{
aNewSpec = devSpec;
NS_ADDREF(aNewSpec);
}
}
return rv;
}

View File

@@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecFactoryB_h___
#define nsDeviceContextSpecFactoryB_h___
#include "nsIDeviceContextSpecFactory.h"
#include "nsIDeviceContextSpec.h"
class nsDeviceContextSpecFactoryBeOS : public nsIDeviceContextSpecFactory
{
public:
nsDeviceContextSpecFactoryBeOS();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(void);
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryBeOS();
};
#endif

View File

@@ -1,277 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDrawingSurfaceBeOS.h"
#include "nsCoord.h"
NS_IMPL_ISUPPORTS2(nsDrawingSurfaceBeOS, nsIDrawingSurface, nsIDrawingSurfaceBeOS)
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
static PRTime mLockTime, mUnlockTime;
#endif
nsDrawingSurfaceBeOS :: nsDrawingSurfaceBeOS()
{
NS_INIT_REFCNT();
mView = NULL;
mBitmap = nsnull;
mWidth = 0;
mHeight = 0;
mLockWidth = 0;
mLockHeight = 0;
mLockFlags = 0;
mLockX = 0;
mLockY = 0;
mLocked = PR_FALSE;
}
nsDrawingSurfaceBeOS :: ~nsDrawingSurfaceBeOS()
{
if(mBitmap)
{
mBitmap->RemoveChild(mView);
delete mBitmap;
}
}
/**
* Lock a rect of a drawing surface and return a
* pointer to the upper left hand corner of the
* bitmap.
* @param aX x position of subrect of bitmap
* @param aY y position of subrect of bitmap
* @param aWidth width of subrect of bitmap
* @param aHeight height of subrect of bitmap
* @param aBits out parameter for upper left hand
* corner of bitmap
* @param aStride out parameter for number of bytes
* to add to aBits to go from scanline to scanline
* @param aWidthBytes out parameter for number of
* bytes per line in aBits to process aWidth pixels
* @return error status
*
**/
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
mLockTime = PR_Now();
// MOZ_TIMER_RESET(mLockTime);
// MOZ_TIMER_START(mLockTime);
#endif
if (mLocked)
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
// Obtain an ximage from the pixmap. ( I think this copy the bitmap )
// FIX ME !!!! We need to copy the part locked into the mImage
mView->LockLooper();
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
// MOZ_TIMER_STOP(mLockTime);
// MOZ_TIMER_LOG(("Time taken to lock: "));
// MOZ_TIMER_PRINT(mLockTime);
printf("Time taken to lock: %d\n", PR_Now() - mLockTime);
#endif
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Unlock(void)
{
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
mUnlockTime = PR_Now();
#endif
// g_print("nsDrawingSurfaceGTK::UnLock() called\n");
if (!mLocked)
{
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
return NS_ERROR_FAILURE;
}
// If the lock was not read only, put the bits back on the pixmap
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
{
// FIX ME!!!
// Now draw the image ...
}
// FIX ME!!!
// Destroy mImage
mView->UnlockLooper();
mLocked = PR_FALSE;
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
printf("Time taken to unlock: %d\n", PR_Now() - mUnlockTime);
#endif
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mIsOffscreen;//mBitmap ? PR_TRUE : PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsPixelAddressable(PRBool *aAddressable)
{
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView)
{
if(aView->LockLooper())
{
//remember dimensions
mWidth=nscoord(aView->Bounds().Width()+1);
mHeight=nscoord(aView->Bounds().Height()+1);
mView = aView;
aView->UnlockLooper();
}
// XXX was i smoking crack when i wrote this comment?
// this is definatly going to be on the screen, as it will be the window of a
// widget or something.
mIsOffscreen = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags)
{
NS_ASSERTION(!(aView == nsnull), "null BView");
//remember dimensions
mWidth=aWidth;
mHeight=aHeight;
mFlags = aFlags;
// we can draw on this offscreen because it has no parent
mIsOffscreen = PR_TRUE;
BRect r(0,0, mWidth-1, mHeight-1);
mView = new BView(r, "", 0, 0);
if (!mView)
return NS_ERROR_OUT_OF_MEMORY;
//if((aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS) &&
// (aWidth > 0) && (aHeight > 0))
if(aWidth > 0 && aHeight > 0)
{
mBitmap = new BBitmap(r, B_RGBA32, true);
if (!mBitmap)
return NS_ERROR_OUT_OF_MEMORY;
if (mBitmap->InitCheck()!=B_OK) {
//for some reason, the bitmap isn't valid - delete the
//bitmap object, then indicate failure
delete mBitmap;
mBitmap=NULL;
return NS_ERROR_FAILURE;
}
mBitmap->AddChild(mView);
}
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireView(BView **aView)
{
*aView = mView;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireBitmap(BBitmap **aBitmap)
{
if(mBitmap && mBitmap->Lock())
{
mView->Sync();
mBitmap->Unlock();
}
*aBitmap = mBitmap;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseView(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseBitmap(void)
{
return NS_OK;
}

View File

@@ -1,103 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDrawingSurfaceBeOS_h___
#define nsDrawingSurfaceBeOS_h___
#include "nsIDrawingSurface.h"
#include "nsIDrawingSurfaceBeOS.h"
#include <Bitmap.h>
#include <View.h>
class nsDrawingSurfaceBeOS : public nsIDrawingSurface,
public nsIDrawingSurfaceBeOS
{
public:
nsDrawingSurfaceBeOS();
virtual ~nsDrawingSurfaceBeOS();
NS_DECL_ISUPPORTS
//nsIDrawingSurface interface
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
// local methods
NS_IMETHOD Init(BView *aView);
NS_IMETHOD Init(BView *aView, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags);
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
NS_IMETHOD AcquireView(BView **aView);
NS_IMETHOD ReleaseView(void);
NS_IMETHOD AcquireBitmap(BBitmap **aBitmap);
NS_IMETHOD ReleaseBitmap(void);
void GetSize(PRUint32 *aWidth, PRUint32 *aHeight) { *aWidth = mWidth; *aHeight = mHeight; }
private:
BView *mView;
BBitmap *mBitmap;
nsPixelFormat mPixFormat;
PRUint32 mWidth;
PRUint32 mHeight;
PRUint32 mFlags;
PRBool mIsOffscreen;
/* for locks */
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
};
#endif

View File

@@ -1,563 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Yannick Koehler <koehler@mythrium.com>
* Christian M Hoffman <chrmhoffmann@web.de>
* Makoto hamanaka <VYA04230@nifty.com>
* Paul Ashford <arougthopher@lizardland.net>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "xp_core.h"
#include "nsQuickSort.h"
#include "nsFontMetricsBeOS.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetConverterManager2.h"
#include "nsISaveAsCharset.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nspr.h"
#include "nsHashtable.h"
#include "nsReadableUtils.h"
#undef USER_DEFINED
#define USER_DEFINED "x-user-def"
#undef NOISY_FONTS
#undef REALLY_NOISY_FONTS
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
nsFontMetricsBeOS::nsFontMetricsBeOS()
:mEmulateBold(PR_FALSE)
{
NS_INIT_REFCNT();
}
nsFontMetricsBeOS::~nsFontMetricsBeOS()
{
if (nsnull != mFont) {
delete mFont;
mFont = nsnull;
}
if (mDeviceContext) {
// Notify our device context that owns us so that it can update its font cache
mDeviceContext->FontMetricsDeleted(this);
mDeviceContext = nsnull;
}
}
NS_IMPL_ISUPPORTS1(nsFontMetricsBeOS, nsIFontMetrics)
static PRBool
IsASCIIFontName(const nsString& aName)
{
PRUint32 len = aName.Length();
const PRUnichar* str = aName.get();
for (PRUint32 i = 0; i < len; i++) {
/*
* X font names are printable ASCII, ignore others (for now)
*/
if ((str[i] < 0x20) || (str[i] > 0x7E)) {
return PR_FALSE;
}
}
return PR_TRUE;
}
// a structure to hold a font family list
typedef struct nsFontEnumParamsBeOS {
nsFontMetricsBeOS *metrics;
nsStringArray family;
nsVoidArray isgeneric;
} NS_FONT_ENUM_PARAMS_BEOS;
// a callback func to get a font family list from a nsFont object
static PRBool FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData)
{
NS_FONT_ENUM_PARAMS_BEOS *param = (NS_FONT_ENUM_PARAMS_BEOS *) aData;
param->family.AppendString(aFamily);
param->isgeneric.AppendElement((void*) aGeneric);
if (aGeneric)
return PR_FALSE;
return PR_TRUE;
}
NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext* aContext)
{
NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");
mLangGroup = aLangGroup;
mDeviceContext = aContext;
// get font family list
NS_FONT_ENUM_PARAMS_BEOS param;
param.metrics = this;
aFont.EnumerateFamilies(FontEnumCallback, &param);
PRInt16 face = 0;
mFont = new nsFont(aFont);
float app2dev, app2twip;
aContext->GetAppUnitsToDevUnits(app2dev);
aContext->GetDevUnitsToTwips(app2twip);
float textZoom = 1.0;
aContext->GetTextZoom(textZoom);
app2twip *= app2dev;
float rounded = ((float)NSIntPointsToTwips(NSTwipsToFloorIntPoints(nscoord(mFont->size * app2twip * textZoom)))) / app2twip;
// process specified fonts from first item of the array.
// stop processing next when a real font found;
PRBool fontfound = PR_FALSE;
for (int i=0 ; i<param.family.Count() && !fontfound ; i++) {
nsString *fam = param.family.StringAt(i);
PRBool isgeneric = ( param.isgeneric[i] ) ? PR_TRUE: PR_FALSE;
char *family = ToNewUTF8String(*fam);
if (!isgeneric) {
// non-generic font
if ( count_font_styles((font_family)family) <= 0) {
// the specified font is not exist in this computer.
nsMemory::Free(family);
continue;
}
mFontHandle.SetFamilyAndStyle( (font_family)family, NULL );
nsMemory::Free(family);
fontfound = PR_TRUE;
break;
}
else {
// family is generic string like
// "serif" "sans-serif" "cursive" "fantasy" "monospace" "-moz-fixed"
// so look up preferences and get real family name
const PRUnichar *langGroup;
aLangGroup->GetUnicode( &langGroup );
char *lang = ToNewUTF8String(nsDependentString(langGroup));
char prop[256];
sprintf( prop, "font.name.%s.%s", family, lang );
nsMemory::Free(lang);
nsMemory::Free(family);
// look up prefs
char *real_family = NULL;
nsresult res = NS_ERROR_FAILURE;
//NS_WITH_SERVICE( nsIPref, prefs, kPrefCID, &res );
nsCOMPtr<nsIPref> prefs = do_GetService( kPrefCID, &res );
if( res == NS_OK ) {
prefs->CopyCharPref( prop, &real_family );
if ( (real_family) && count_font_styles((font_family)real_family) > 0) {
mFontHandle.SetFamilyAndStyle( (font_family)real_family, NULL );
fontfound = PR_TRUE;
break;
}
}
// not successful. use normal font.
mFontHandle = be_plain_font;
fontfound = PR_TRUE;
break;
}
}
// if got no font, then use system font.
if (!fontfound)
mFontHandle = be_plain_font;
if (aFont.style == NS_FONT_STYLE_ITALIC)
face |= B_ITALIC_FACE;
if( aFont.weight > NS_FONT_WEIGHT_NORMAL )
face |= B_BOLD_FACE;
// I don't think B_UNDERSCORE_FACE and B_STRIKEOUT_FACE really works...
// instead, nsTextFrame do them for us. ( my guess... Makoto Hamanaka )
if( aFont.decorations & NS_FONT_DECORATION_UNDERLINE )
face |= B_UNDERSCORE_FACE;
if( aFont.decorations & NS_FONT_DECORATION_LINE_THROUGH )
face |= B_STRIKEOUT_FACE;
mFontHandle.SetFace( face );
// emulate italic and bold if the selected family has no such style
if (aFont.style == NS_FONT_STYLE_ITALIC
&& !(mFontHandle.Face() & B_ITALIC_FACE)) {
mFontHandle.SetShear(105.0);
}
if ( aFont.weight > NS_FONT_WEIGHT_NORMAL
&& !(mFontHandle.Face() & B_BOLD_FACE)) {
mEmulateBold = PR_TRUE;
}
mFontHandle.SetSize( rounded * app2dev );
#ifdef NOISY_FONTS
#ifdef DEBUG
fprintf(stderr, "looking for font %s (%d)", wildstring, aFont.size / app2twip);
#endif
#endif
RealizeFont(aContext);
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::Destroy()
{
mDeviceContext = nsnull;
return NS_OK;
}
void nsFontMetricsBeOS::RealizeFont(nsIDeviceContext* aContext)
{
float f;
aContext->GetDevUnitsToAppUnits(f);
struct font_height height;
mFontHandle.GetHeight( &height );
struct font_height emHeight;
be_plain_font->GetHeight(&emHeight);
int lineSpacing = nscoord(height.ascent + height.descent);
if (lineSpacing > (emHeight.ascent + emHeight.descent)) {
mLeading = nscoord((lineSpacing - (emHeight.ascent + emHeight.descent)) * f);
}
else {
mLeading = 0;
}
mEmHeight = PR_MAX(1, nscoord((emHeight.ascent + emHeight.descent) * f));
mEmAscent = nscoord(height.ascent * (emHeight.ascent + emHeight.descent) * f / lineSpacing);
mEmDescent = mEmHeight - mEmAscent;
mMaxHeight = nscoord((height.ascent +
height.descent) * f) ;
mMaxAscent = nscoord(height.ascent * f) ;
mMaxDescent = nscoord(height.descent * f);
mMaxAdvance = nscoord(mFontHandle.BoundingBox().Width() * f);
// 56% of ascent, best guess for non-true type
mXHeight = NSToCoordRound((float) height.ascent* f * 0.56f);
float rawWidth = mFontHandle.StringWidth(" ");
mSpaceWidth = NSToCoordRound(rawWidth * f);
/* Temp */
mUnderlineOffset = -NSToIntRound(MAX (1, floor (0.1 * (height.ascent + height.descent + height.leading) + 0.5)) * f);
mUnderlineSize = NSToIntRound(MAX(1, floor (0.05 * (height.ascent + height.descent + height.leading) + 0.5)) * f);
mSuperscriptOffset = mXHeight;
mSubscriptOffset = mXHeight;
/* need better way to calculate this */
mStrikeoutOffset = NSToCoordRound(mXHeight / 2.0);
mStrikeoutSize = mUnderlineSize;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetXHeight(nscoord& aResult)
{
aResult = mXHeight;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetSuperscriptOffset(nscoord& aResult)
{
aResult = mSuperscriptOffset;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetSubscriptOffset(nscoord& aResult)
{
aResult = mSubscriptOffset;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetStrikeout(nscoord& aOffset, nscoord& aSize)
{
aOffset = mStrikeoutOffset;
aSize = mStrikeoutSize;
// aOffset = nscoord( ( mAscent / 2 ) - mDescent );
// aSize = nscoord( 20 ); // FIXME Put 1 pixel which equal 20 twips..
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetUnderline(nscoord& aOffset, nscoord& aSize)
{
aOffset = mUnderlineOffset;
aSize = mUnderlineSize;
//aOffset = nscoord( 0 ); // FIXME
//aSize = nscoord( 20 ); // FIXME
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetHeight(nscoord &aHeight)
{
aHeight = mMaxHeight;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetNormalLineHeight(nscoord &aHeight)
{
aHeight = mEmHeight + mLeading;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetLeading(nscoord &aLeading)
{
aLeading = mLeading;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetEmHeight(nscoord &aHeight)
{
aHeight = mEmHeight;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetEmAscent(nscoord &aAscent)
{
aAscent = mEmAscent;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetEmDescent(nscoord &aDescent)
{
aDescent = mEmDescent;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetMaxHeight(nscoord &aHeight)
{
aHeight = mMaxHeight;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetMaxAscent(nscoord &aAscent)
{
aAscent = mMaxAscent;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetMaxDescent(nscoord &aDescent)
{
aDescent = mMaxDescent;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetMaxAdvance(nscoord &aAdvance)
{
aAdvance = mMaxAdvance;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetSpaceWidth(nscoord &aSpaceWidth)
{
aSpaceWidth = mSpaceWidth;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetFont(const nsFont*& aFont)
{
aFont = mFont;
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetLangGroup(nsIAtom** aLangGroup)
{
if (!aLangGroup) {
return NS_ERROR_NULL_POINTER;
}
*aLangGroup = mLangGroup;
NS_IF_ADDREF(*aLangGroup);
return NS_OK;
}
NS_IMETHODIMP nsFontMetricsBeOS::GetFontHandle(nsFontHandle &aHandle)
{
aHandle = (nsFontHandle)&mFontHandle;
return NS_OK;
}
nsresult
nsFontMetricsBeOS::FamilyExists(const nsString& aName)
{
if (!IsASCIIFontName(aName)) {
return NS_ERROR_FAILURE;
}
nsCAutoString name;
name.AssignWithConversion(aName.get());
ToLowerCase(name);
PRBool isthere = PR_FALSE;
char* cStr = ToNewCString(name);
int32 numFamilies = count_font_families();
for(int32 i = 0; i < numFamilies; i++) {
font_family family;
uint32 flags;
if(get_font_family(i, &family, &flags) == B_OK) {
if(strcmp(family, cStr) == 0) {
isthere = PR_TRUE;
break;
}
}
}
//printf("%s there? %s\n", cStr, isthere?"Yes":"No" );
delete[] cStr;
if (PR_TRUE == isthere)
return NS_OK;
else
return NS_ERROR_FAILURE;
}
// The Font Enumerator
nsFontEnumeratorBeOS::nsFontEnumeratorBeOS()
{
NS_INIT_REFCNT();
}
NS_IMPL_ISUPPORTS1(nsFontEnumeratorBeOS, nsIFontEnumerator)
static int
CompareFontNames(const void* aArg1, const void* aArg2, void* aClosure)
{
const PRUnichar* str1 = *((const PRUnichar**) aArg1);
const PRUnichar* str2 = *((const PRUnichar**) aArg2);
// XXX add nsICollation stuff
return nsCRT::strcmp(str1, str2);
}
static nsresult
EnumFonts(nsIAtom* aLangGroup, const char* aGeneric, PRUint32* aCount,
PRUnichar*** aResult)
{
nsString font_name;
int32 numFamilies = count_font_families();
PRUnichar** array =
(PRUnichar**) nsMemory::Alloc(numFamilies * sizeof(PRUnichar*));
if (!array) {
return NS_ERROR_OUT_OF_MEMORY;
}
for(int32 i = 0; i < numFamilies; i++) {
font_family family;
uint32 flags;
if(get_font_family(i, &family, &flags) == B_OK) {
font_name.AssignWithConversion(family);
array[i] = ToNewUnicode(font_name);
}
}
NS_QuickSort(array, numFamilies, sizeof(PRUnichar*), CompareFontNames,
nsnull);
*aCount = numFamilies;
if (*aCount) {
*aResult = array;
}
else {
nsMemory::Free(array);
}
return NS_OK;
}
NS_IMETHODIMP
nsFontEnumeratorBeOS::EnumerateAllFonts(PRUint32* aCount, PRUnichar*** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nsnull;
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
return EnumFonts(nsnull, nsnull, aCount, aResult);
}
NS_IMETHODIMP
nsFontEnumeratorBeOS::EnumerateFonts(const char* aLangGroup,
const char* aGeneric, PRUint32* aCount, PRUnichar*** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nsnull;
NS_ENSURE_ARG_POINTER(aCount);
*aCount = 0;
NS_ENSURE_ARG_POINTER(aGeneric);
NS_ENSURE_ARG_POINTER(aLangGroup);
nsCOMPtr<nsIAtom> langGroup = getter_AddRefs(NS_NewAtom(aLangGroup));
// XXX still need to implement aLangGroup and aGeneric
return EnumFonts(langGroup, aGeneric, aCount, aResult);
}
NS_IMETHODIMP
nsFontEnumeratorBeOS::HaveFontFor(const char* aLangGroup, PRBool* aResult)
{
NS_ENSURE_ARG_POINTER(aLangGroup);
NS_ENSURE_ARG_POINTER(aResult);
*aResult = PR_FALSE;
// XXX stub
return NS_OK;
}
NS_IMETHODIMP
nsFontEnumeratorBeOS::UpdateFontList(PRBool *updateFontList)
{
*updateFontList = PR_FALSE; // always return false for now
return NS_OK;
}

View File

@@ -1,137 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Paul Ashford <arougthopher@lizardland.net>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFontMetricsBeOS_h__
#define nsFontMetricsBeOS_h__
#include "nsDeviceContextBeOS.h"
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsRenderingContextBeOS.h"
#include "nsICharRepresentable.h"
#include <Font.h>
class nsFontMetricsBeOS : public nsIFontMetrics
{
public:
nsFontMetricsBeOS();
virtual ~nsFontMetricsBeOS();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
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);
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
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 GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
static nsresult FamilyExists(const nsString& aFontName);
inline PRBool GetEmulateBold() { return mEmulateBold; }
nsCOMPtr<nsIAtom> mLangGroup;
protected:
void RealizeFont(nsIDeviceContext* aContext);
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
BFont mFontHandle;
nscoord mLeading;
nscoord mEmHeight;
nscoord mEmAscent;
nscoord mEmDescent;
nscoord mMaxHeight;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
nscoord mSpaceWidth;
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
PRBool mEmulateBold;
};
class nsFontEnumeratorBeOS : public nsIFontEnumerator
{
public:
nsFontEnumeratorBeOS();
NS_DECL_ISUPPORTS
NS_DECL_NSIFONTENUMERATOR
};
#endif

View File

@@ -1,189 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsBlender.h"
#include "nsFontMetricsBeOS.h"
#include "nsRenderingContextBeOS.h"
// aka nsDeviceContextSpecBeOS.h
#include "nsDeviceContextSpecB.h"
// aka nsDeviceContextSpecFactoryBeOS.h
#include "nsDeviceContextSpecFactoryB.h"
#include "nsScreenManagerBeOS.h"
#include "nsScriptableRegion.h"
#include "nsDeviceContextBeOS.h"
#include "nsPrintOptionsBeOS.h"
#include "nsImageBeOS.h"
#include "nsFontList.h"
// objects that just require generic constructors
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorBeOS)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsBeOS)
// our custom constructors
static NS_IMETHODIMP nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsresult rv;
nsIScriptableRegion *inst;
if ( !aResult )
{
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = nsnull;
if (aOuter)
{
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
// create an nsRegionBeOS and get the scriptable region from it
nsCOMPtr <nsIRegion> rgn;
NS_NEWXPCOM(rgn, nsRegionBeOS);
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 nsModuleComponentInfo components[] =
{
{ "BeOS Font Metrics",
NS_FONT_METRICS_CID,
// "@mozilla.org/gfx/font_metrics/beos;1",
"@mozilla.org/gfx/fontmetrics;1",
nsFontMetricsBeOSConstructor },
{ "BeOS Device Context",
NS_DEVICE_CONTEXT_CID,
// "@mozilla.org/gfx/device_context/beos;1",
"@mozilla.org/gfx/devicecontext;1",
nsDeviceContextBeOSConstructor },
{ "BeOS Rendering Context",
NS_RENDERING_CONTEXT_CID,
// "@mozilla.org/gfx/rendering_context/beos;1",
"@mozilla.org/gfx/renderingcontext;1",
nsRenderingContextBeOSConstructor },
{ "BeOS Image",
NS_IMAGE_CID,
// "@mozilla.org/gfx/image/beos;1",
"@mozilla.org/gfx/image;1",
nsImageBeOSConstructor },
{ "BeOS Region",
NS_REGION_CID,
"@mozilla.org/gfx/region/beos;1",
nsRegionBeOSConstructor },
{ "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 },
{ "BeOS Device Context Spec",
NS_DEVICE_CONTEXT_SPEC_CID,
// "@mozilla.org/gfx/device_context_spec/beos;1",
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecBeOSConstructor },
{ "BeOS Device Context Spec Factory",
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
// "@mozilla.org/gfx/device_context_spec_factory/beos;1",
"@mozilla.org/gfx/devicecontextspecfactory;1",
nsDeviceContextSpecFactoryBeOSConstructor },
{ "BeOS Font Enumerator",
NS_FONT_ENUMERATOR_CID,
// "@mozilla.org/gfx/font_enumerator/beos;1",
"@mozilla.org/gfx/fontenumerator;1",
nsFontEnumeratorBeOSConstructor },
{ "Font List",
NS_FONTLIST_CID,
// "@mozilla.org/gfx/fontlist;1"
NS_FONTLIST_CONTRACTID,
nsFontListConstructor },
{ "BeOS Screen Manager",
NS_SCREENMANAGER_CID,
// "@mozilla.org/gfx/screenmanager/beos;1",
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerBeOSConstructor },
{ "BeOS Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
// "@mozilla.org/gfx/printer_enumerator/beos;1",
"@mozilla.org/gfx/printerenumerator;1",
nsPrinterEnumeratorBeOSConstructor },
{ "BeOS Printer Options",
NS_PRINTOPTIONS_CID,
"@mozilla.org/gfx/printoptions;1",
nsPrintOptionsBeOSConstructor }
};
NS_IMPL_NSGETMODULE(nsGfxBeOSModule, components)

View File

@@ -1,141 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsGraphicsStateBeOS.h"
//////////////////////////////////////////////////////////////////////////
nsGraphicsState::nsGraphicsState()
{
mMatrix = nsnull;
mClipRegion = nsnull;
mColor = 0;
mLineStyle = nsLineStyle_kSolid;
mFontMetrics = nsnull;
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsState::~nsGraphicsState()
{
NS_IF_RELEASE(mFontMetrics);
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool::nsGraphicsStatePool()
{
mFreeList = nsnull;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Public nsGraphicsStatePool
//
//////////////////////////////////////////////////////////////////////////
/* static */ nsGraphicsState *
nsGraphicsStatePool::GetNewGS()
{
nsGraphicsStatePool * thePool = PrivateGetPool();
return thePool->PrivateGetNewGS();
}
//////////////////////////////////////////////////////////////////////////
/* static */ void
nsGraphicsStatePool::ReleaseGS(nsGraphicsState* aGS)
{
nsGraphicsStatePool * thePool = PrivateGetPool();
thePool->PrivateReleaseGS(aGS);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Private nsGraphicsStatePool
//
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool *
nsGraphicsStatePool::gsThePool = nsnull;
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool *
nsGraphicsStatePool::PrivateGetPool()
{
if (nsnull == gsThePool)
{
gsThePool = new nsGraphicsStatePool();
}
return gsThePool;
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool::~nsGraphicsStatePool()
{
nsGraphicsState* gs = mFreeList;
while (gs != nsnull) {
nsGraphicsState* next = gs->mNext;
delete gs;
gs = next;
}
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsState *
nsGraphicsStatePool::PrivateGetNewGS()
{
nsGraphicsState* gs = mFreeList;
if (gs != nsnull) {
mFreeList = gs->mNext;
return gs;
}
return new nsGraphicsState;
}
//////////////////////////////////////////////////////////////////////////
void
nsGraphicsStatePool::PrivateReleaseGS(nsGraphicsState* aGS)
{
// aGS->Clear();
aGS->mNext = mFreeList;
mFreeList = aGS;
}
//////////////////////////////////////////////////////////////////////////

View File

@@ -1,91 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsGraphicsStateBeOS_h___
#define nsGraphicsStateBeOS_h___
#include "nsIRenderingContext.h"
#include "nsIFontMetrics.h"
#include "nsTransform2D.h"
#include "nsRegionBeOS.h"
#include "nsCOMPtr.h"
class nsGraphicsState
{
public:
nsTransform2D *mMatrix;
nsCOMPtr<nsIRegion> mClipRegion;
nscolor mColor;
nsLineStyle mLineStyle;
nsIFontMetrics *mFontMetrics;
nsGraphicsState *mNext; // link into free list of graphics states.
friend class nsGraphicsStatePool;
#ifndef USE_GS_POOL
friend class nsRenderingContextBeOS;
#endif
private:
nsGraphicsState();
~nsGraphicsState();
};
class nsGraphicsStatePool
{
public:
static nsGraphicsState * GetNewGS();
static void ReleaseGS(nsGraphicsState* aGS);
nsGraphicsStatePool();
~nsGraphicsStatePool();
private:
nsGraphicsState* mFreeList;
static nsGraphicsStatePool * PrivateGetPool();
nsGraphicsState * PrivateGetNewGS();
void PrivateReleaseGS(nsGraphicsState* aGS);
static nsGraphicsStatePool * gsThePool;
};
#endif /* nsGraphicsStateBeOS_h___ */

View File

@@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDrawingSurfaceBeOS_h___
#define nsIDrawingSurfaceBeOS_h___
#include "nsIDrawingSurface.h"
#include <View.h>
// windows specific drawing surface method set
#define NS_IDRAWING_SURFACE_BEOS_IID \
{ 0x1ed958b0, 0xcab6, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDrawingSurfaceBeOS : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAWING_SURFACE_BEOS_IID)
/**
* Initialize a drawing surface using a windows DC.
* aDC is "owned" by the drawing surface until the drawing
* surface is destroyed.
* @param aDC HDC to initialize drawing surface with
* @return error status
**/
NS_IMETHOD Init(BView *aView) = 0;
/**
* Initialize an offscreen drawing surface using a
* windows DC. aDC is not "owned" by this drawing surface, instead
* it is used to create a drawing surface compatible
* with aDC. if width or height are less than zero, aDC will
* be created with no offscreen bitmap installed.
* @param aDC HDC to initialize drawing surface with
* @param aWidth width of drawing surface
* @param aHeight height of drawing surface
* @param aFlags flags used to control type of drawing
* surface created
* @return error status
**/
NS_IMETHOD Init(BView *aView, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags) = 0;
};
#endif // nsIDrawingSurfaceBeOS_h___

View File

@@ -1,712 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsImageBeOS.h"
#include "nsRenderingContextBeOS.h"
#include "nspr.h"
//#include <string.h>
#include "imgScaler.h"
#define IsFlagSet(a,b) (a & b)
NS_IMPL_ISUPPORTS1(nsImageBeOS, nsIImage)
//------------------------------------------------------------
nsImageBeOS::nsImageBeOS()
{
NS_INIT_REFCNT();
mStaticImage = PR_FALSE;
mImageBits = nsnull;
mWidth = 0;
mHeight = 0;
mDepth = 0;
mAlphaBits = nsnull;
mAlphaDepth = 0;
mRowBytes = 0;
mSizeImage = 0;
mAlphaHeight = 0;
mAlphaWidth = 0;
mImage = nsnull;
mNaturalWidth = 0;
mNaturalHeight = 0;
}
//------------------------------------------------------------
nsImageBeOS::~nsImageBeOS()
{
if (NULL != mImage) {
delete mImage;
mImage = NULL;
}
if(nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
}
//------------------------------------------------------------
nsresult
nsImageBeOS::Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth, nsMaskRequirements aMaskRequirements)
{
if (nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
SetDecodedRect(0,0,0,0); //init
SetNaturalWidth(0);
SetNaturalHeight(0);
if (24 == aDepth) {
mNumBytesPixel = 3;
} else {
NS_ASSERTION(PR_FALSE, "unexpected image depth");
return NS_ERROR_UNEXPECTED;
}
mWidth = aWidth;
mHeight = aHeight;
mDepth = aDepth;
mIsTopToBottom = PR_TRUE;
// create the memory for the image
ComputeMetrics();
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
switch(aMaskRequirements)
{
case nsMaskRequirements_kNoMask:
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
break;
case nsMaskRequirements_kNeeds1Bit:
mAlphaRowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
// 32-bit align each row
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
memset(mAlphaBits, 255, mAlphaRowBytes * aHeight);
mAlphaWidth = aWidth;
mAlphaHeight = aHeight;
break;
case nsMaskRequirements_kNeeds8Bit:
mAlphaRowBytes = aWidth;
mAlphaDepth = 8;
// 32-bit align each row
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
mAlphaWidth = aWidth;
mAlphaHeight = aHeight;
break;
}
return NS_OK;
}
//------------------------------------------------------------
PRInt32 nsImageBeOS::GetHeight()
{
return mHeight;
}
PRInt32 nsImageBeOS::GetWidth()
{
return mWidth;
}
PRUint8 *nsImageBeOS::GetBits()
{
return mImageBits;
}
void *nsImageBeOS::GetBitInfo()
{
return nsnull;
}
PRInt32 nsImageBeOS::GetLineStride()
{
return mRowBytes;
}
nsColorMap *nsImageBeOS::GetColorMap()
{
return nsnull;
}
PRBool nsImageBeOS::IsOptimized()
{
return mStaticImage;
}
PRUint8 *nsImageBeOS::GetAlphaBits()
{
return mAlphaBits;
}
PRInt32 nsImageBeOS::GetAlphaWidth()
{
return mAlphaWidth;
}
PRInt32 nsImageBeOS::GetAlphaHeight()
{
return mAlphaHeight;
}
PRInt32 nsImageBeOS::GetAlphaLineStride()
{
return mAlphaRowBytes;
}
nsIImage *nsImageBeOS::DuplicateImage()
{
return nsnull;
}
void nsImageBeOS::SetAlphaLevel(PRInt32 aAlphaLevel)
{
}
PRInt32 nsImageBeOS::GetAlphaLevel()
{
return 0;
}
void nsImageBeOS::MoveAlphaMask(PRInt32 aX, PRInt32 aY)
{
}
//------------------------------------------------------------
// set up the palette to the passed in color array, RGB only in this array
void
nsImageBeOS::ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags,
nsRect *aUpdateRect)
{
mFlags = aFlags; // this should be 0'd out by Draw()
}
// Draw the bitmap, this method has a source and destination coordinates
NS_IMETHODIMP
nsImageBeOS::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
nsDrawingSurfaceBeOS *beosdrawing =(nsDrawingSurfaceBeOS *) aSurface;
BView *view;
beosdrawing->AcquireView(&view);
if((PR_FALSE == mStaticImage) || (NULL == mImage))
BuildImage(aSurface);
if(NULL == mImage)
return PR_FALSE;
if(view && view->LockLooper())
{
view->SetDrawingMode(B_OP_ALPHA);
view->DrawBitmapAsync(mImage, BRect(aSX, aSY, aSX + aSWidth - 1, aSY + aSHeight - 1),
BRect(aDX, aDY, aDX + aDWidth - 1, aDY + aDHeight - 1));
view->SetDrawingMode(B_OP_COPY);
view->Sync();
view->UnlockLooper();
}
beosdrawing->ReleaseView();
return NS_OK;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
NS_IMETHODIMP
nsImageBeOS::Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
// XXX kipp: this is temporary code until we eliminate the
// width/height arguments from the draw method.
aWidth = PR_MIN(aWidth, mWidth);
aHeight = PR_MIN(aHeight, mHeight);
nsDrawingSurfaceBeOS *beosdrawing = (nsDrawingSurfaceBeOS *) aSurface;
BView *view;
beosdrawing->AcquireView(&view);
if((PR_FALSE == mStaticImage) || (NULL == mImage))
BuildImage(aSurface);
if(NULL == mImage)
return PR_FALSE;
if(view && view->LockLooper())
{
view->SetDrawingMode(B_OP_ALPHA);
view->DrawBitmapAsync(mImage,
BRect(0, 0, aWidth - 1, aHeight - 1),
BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
view->SetDrawingMode(B_OP_COPY);
view->Sync();
view->UnlockLooper();
}
beosdrawing->ReleaseView();
return NS_OK;
}
/**
* Draw a tiled version of the bitmap
* @update - dwc 3/30/00
* @param aSurface the surface to blit to
* @param aX0 starting x
* @param aY0 starting y
* @param aX1 ending x
* @param aY1 ending y
* @param aWidth The destination width of the pixelmap
* @param aHeight The destination height of the pixelmap
*/
NS_IMETHODIMP nsImageBeOS::DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
nsRect &aSrcRect,
nsRect &aTileRect)
{
PRInt32 aY0 = aTileRect.y,
aX0 = aTileRect.x,
aY1 = aTileRect.y + aTileRect.height,
aX1 = aTileRect.x + aTileRect.width;
for (PRInt32 y = aY0; y < aY1; y+=aSrcRect.height)
for (PRInt32 x = aX0; x < aX1; x+=aSrcRect.width)
Draw(aContext,aSurface,x,y,
PR_MIN(aSrcRect.width, aX1-x),
PR_MIN(aSrcRect.height, aY1-y));
return NS_OK;
}
NS_IMETHODIMP nsImageBeOS::DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
const nsRect &aTileRect)
{
PRInt32
validX = 0,
validY = 0,
validWidth = mWidth,
validHeight = mHeight;
// limit the image rectangle to the size of the image data which
// has been validated.
if ((mDecodedY2 < mHeight)) {
validHeight = mDecodedY2 - mDecodedY1;
}
if ((mDecodedX2 < mWidth)) {
validWidth = mDecodedX2 - mDecodedX1;
}
if ((mDecodedY1 > 0)) {
validHeight -= mDecodedY1;
validY = mDecodedY1;
}
if ((mDecodedX1 > 0)) {
validWidth -= mDecodedX1;
validX = mDecodedX1;
}
PRInt32 aY0 = aTileRect.y - aSYOffset,
aX0 = aTileRect.x - aSXOffset,
aY1 = aTileRect.y + aTileRect.height,
aX1 = aTileRect.x + aTileRect.width;
// Set up clipping and call Draw().
PRBool clipState;
aContext.PushState();
aContext.SetClipRect(aTileRect, nsClipCombine_kIntersect,
clipState);
for (PRInt32 y = aY0; y < aY1; y+=validHeight)
for (PRInt32 x = aX0; x < aX1; x+=validWidth)
Draw(aContext,aSurface,x,y, PR_MIN(validWidth, aX1-x),
PR_MIN(validHeight, aY1-y));
aContext.PopState(clipState);
return NS_OK;
}
nsresult nsImageBeOS::BuildImage(nsDrawingSurface aDrawingSurface)
{
if(NULL != mImage)
{
delete mImage;
mImage = NULL;
}
// ConvertImage(aDrawingSurface);
CreateImage(aDrawingSurface);
return NS_OK;
}
void nsImageBeOS::CreateImage(nsDrawingSurface aSurface)
{
if(mImageBits)
{
color_space cs;
if(mDepth == 8)
cs = B_CMAP8;
else
cs = B_RGBA32;
mImage = new BBitmap(BRect(0, 0, mWidth - 1, mHeight - 1), cs);
PRInt32 span = (mWidth * mDepth) >> 5;
if (((PRUint32)mWidth * mDepth) & 0x1F)
span++;
span <<= 2;
if( mImage && mImage->IsValid() )
{
uint8 *dest = (uint8*)mImage->Bits();
uint8 *src = mImageBits;
uint8 *alpha = mAlphaBits;
if(mAlphaBits)
{
if( mDepth == 32 )
{
uint32 *pdest, *psrc;
for( int j=0; j<mHeight; j++ )
{
for( int i=0; i<mWidth; i++ )
{
pdest = (uint32*)dest; psrc = (uint32*)src;
// ANSI Shit, can't cast the lvalue!
*pdest = *psrc;
dest[3] = mAlphaDepth == 1 ? ((alpha[i / 8] & (1 << (7 - (i % 8)))) ? 255 : 0) : alpha[i];
dest += 4;
src+=4;
}
src += span - (mWidth*mNumBytesPixel);
alpha += mAlphaRowBytes;
}
}
else if( mDepth == 8 )
{
for( int j=0; j<mHeight; j++ )
{
for( int i=0; i<mWidth * mNumBytesPixel; i++ )
*dest++ = *src++;
src += span - (mWidth*mNumBytesPixel);
}
}
else if( mDepth == 24 )
{
for( int j=0; j<mHeight; j++ )
{
for( int i=0; i<mWidth; i++ )
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = mAlphaDepth == 1 ? ((alpha[i / 8] & (1 << (7 - (i % 8)))) ? 255 : 0) : alpha[i];
dest+= 4;
src+=3;
}
src += span - (mWidth*mNumBytesPixel);
alpha += mAlphaRowBytes;
}
}
}
else
{
if( mDepth == 32 )
{
uint32 *pdest, *psrc;
for( int j=0; j<mHeight; j++ )
{
for( int i=0; i<mWidth; i++ )
{
pdest = (uint32*)dest; psrc = (uint32*)src;
// ANSI Shit, can't cast the lvalue!
*pdest = *psrc;
dest += 4; src+=4;
}
src += span - (mWidth*mNumBytesPixel);
}
}
else if( mDepth == 8 )
{
for( int j=0; j<mHeight; j++ )
{
for( int i=0; i<mWidth * mNumBytesPixel; i++ )
*dest++ = *src++;
src += span - (mWidth*mNumBytesPixel);
}
}
else if( mDepth == 24 )
{
for( int j=0; j<mHeight; j++ )
{
for( int i=0; i<mWidth; i++ )
{
memcpy( dest, src, mNumBytesPixel );
dest[3] = 255;
dest+= 4;
src+=3;
}
src += span - (mWidth*mNumBytesPixel);
}
}
}
}
}
}
//------------------------------------------------------------
nsresult nsImageBeOS::Optimize(nsIDeviceContext* aContext)
{
mStaticImage = PR_TRUE;
return NS_OK;
}
//------------------------------------------------------------
// lock the image pixels. Implement this if you need it.
NS_IMETHODIMP
nsImageBeOS::LockImagePixels(PRBool aMaskPixels)
{
return NS_OK;
}
//------------------------------------------------------------
// unlock the image pixels. Implement this if you need it.
NS_IMETHODIMP
nsImageBeOS::UnlockImagePixels(PRBool aMaskPixels)
{
return NS_OK;
}
// ---------------------------------------------------
// Set the decoded dimens of the image
//
NS_IMETHODIMP
nsImageBeOS::SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2 )
{
mDecodedX1 = x1;
mDecodedY1 = y1;
mDecodedX2 = x2;
mDecodedY2 = y2;
return NS_OK;
}
#ifdef USE_IMG2
NS_IMETHODIMP nsImageBeOS::DrawToImage(nsIImage* aDstImage,
nscoord aDX, nscoord aDY,
nscoord aDWidth, nscoord aDHeight)
{
nsImageBeOS *dest = NS_STATIC_CAST(nsImageBeOS *, aDstImage);
if (!dest)
return NS_ERROR_FAILURE;
if (!dest->mImage)
dest->CreateImage(NULL);
if (!dest->mImage)
return NS_ERROR_FAILURE;
if (!mImage)
CreateImage(NULL);
if (!mImage)
return NS_ERROR_FAILURE;
BBitmap *bmpDst = dest->mImage;
BBitmap bmpTmp(bmpDst->Bounds(), bmpDst->ColorSpace(), true);
BView *v = new BView(bmpDst->Bounds(), "", 0, 0);
if (!v)
return NS_ERROR_OUT_OF_MEMORY;
memcpy( bmpTmp.Bits(), bmpDst->Bits(), bmpDst->BitsLength() );
bmpTmp.AddChild(v);
bmpTmp.Lock();
v->SetDrawingMode(B_OP_ALPHA);
v->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
v->DrawBitmap(mImage, BRect(0, 0, mWidth - 1, mHeight - 1), BRect( aDX, aDY, aDX + aDWidth - 1, aDY + aDHeight -1 ));
v->SetDrawingMode(B_OP_COPY);
v->Sync();
bmpTmp.Unlock();
bmpTmp.RemoveChild(v);
bmpDst->SetBits(bmpTmp.Bits(), bmpTmp.BitsLength(), 0, bmpTmp.ColorSpace() );
delete v;
//
// following part is derived from GTK version
// 2001/6/21 Makoto Hamanaka < VTA04230@nifty.com >
// need to copy the mImageBits in case we're rendered scaled
PRUint8 *scaledImage = 0, *scaledAlpha = 0;
PRUint8 *rgbPtr=0, *alphaPtr=0;
PRUint32 rgbStride, alphaStride;
if ((aDWidth != mWidth) || (aDHeight != mHeight)) {
// scale factor in DrawTo... start scaling
scaledImage = (PRUint8 *)nsMemory::Alloc(3*aDWidth*aDHeight);
if (!scaledImage)
return NS_ERROR_OUT_OF_MEMORY;
RectStretch(0, 0, mWidth-1, mHeight-1, 0, 0, aDWidth-1, aDHeight-1,
mImageBits, mRowBytes, scaledImage, 3*aDWidth, 24);
if (mAlphaDepth) {
if (mAlphaDepth==1)
alphaStride = (aDWidth+7)>>3; // round to next byte
else
alphaStride = aDWidth;
scaledAlpha = (PRUint8 *)nsMemory::Alloc(alphaStride*aDHeight);
if (!scaledAlpha) {
nsMemory::Free(scaledImage);
return NS_ERROR_OUT_OF_MEMORY;
}
RectStretch(0, 0, mWidth-1, mHeight-1, 0, 0, aDWidth-1, aDHeight-1,
mAlphaBits, mAlphaRowBytes, scaledAlpha, alphaStride,
mAlphaDepth);
}
rgbPtr = scaledImage;
rgbStride = 3*aDWidth;
alphaPtr = scaledAlpha;
} else {
rgbPtr = mImageBits;
rgbStride = mRowBytes;
alphaPtr = mAlphaBits;
alphaStride = mAlphaRowBytes;
}
PRInt32 y;
// now composite the two images together
switch (mAlphaDepth) {
case 1:
for (y=0; y<aDHeight; y++) {
PRUint8 *dst = dest->mImageBits + (y+aDY)*dest->mRowBytes + 3*aDX;
PRUint8 *dstAlpha = dest->mAlphaBits + (y+aDY)*dest->mAlphaRowBytes;
PRUint8 *src = rgbPtr + y*rgbStride;
PRUint8 *alpha = alphaPtr + y*alphaStride;
for (int x=0; x<aDWidth; x++, dst+=3, src+=3) {
#define NS_GET_BIT(rowptr, x) (rowptr[(x)>>3] & (1<<(7-(x)&0x7)))
#define NS_SET_BIT(rowptr, x) (rowptr[(x)>>3] |= (1<<(7-(x)&0x7)))
// if this pixel is opaque then copy into the destination image
if (NS_GET_BIT(alpha, x)) {
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
NS_SET_BIT(dstAlpha, aDX+x);
}
#undef NS_GET_BIT
#undef NS_SET_BIT
}
}
break;
case 8:
for (y=0; y<aDHeight; y++) {
PRUint8 *dst = dest->mImageBits + (y+aDY)*dest->mRowBytes + 3*aDX;
PRUint8 *dstAlpha =
dest->mAlphaBits + (y+aDY)*dest->mAlphaRowBytes + aDX;
PRUint8 *src = rgbPtr + y*rgbStride;
PRUint8 *alpha = alphaPtr + y*alphaStride;
for (int x=0; x<aDWidth; x++, dst+=3, dstAlpha++, src+=3, alpha++) {
// blend this pixel over the destination image
unsigned val = *alpha;
MOZ_BLEND(dst[0], dst[0], src[0], val);
MOZ_BLEND(dst[1], dst[1], src[1], val);
MOZ_BLEND(dst[2], dst[2], src[2], val);
MOZ_BLEND(*dstAlpha, *dstAlpha, val, val);
}
}
break;
case 0:
default:
for (y=0; y<aDHeight; y++)
memcpy(dest->mImageBits + (y+aDY)*dest->mRowBytes + 3*aDX,
rgbPtr + y*rgbStride,
3*aDWidth);
}
if (scaledAlpha)
nsMemory::Free(scaledAlpha);
if (scaledImage)
nsMemory::Free(scaledImage);
return NS_OK;
}
#endif

View File

@@ -1,187 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsImageBeOS_h___
#define nsImageBeOS_h___
#include "nsIImage.h"
#include "nsPoint.h"
#include <Bitmap.h>
#undef Bool
class nsImageBeOS : public nsIImage
{
public:
nsImageBeOS();
virtual ~nsImageBeOS();
NS_DECL_ISUPPORTS
/**
@see nsIImage.h
*/
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
virtual PRInt32 GetHeight();
virtual PRInt32 GetWidth();
virtual PRUint8* GetBits();
virtual void* GetBitInfo();
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
virtual PRInt32 GetLineStride();
NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;}
NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;}
virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; }
virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; }
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
virtual PRInt32 GetDecodedX1() { return mDecodedX1;}
virtual PRInt32 GetDecodedY1() { return mDecodedY1;}
virtual PRInt32 GetDecodedX2() { return mDecodedX2;}
virtual PRInt32 GetDecodedY2() { return mDecodedY2;}
virtual nsColorMap* GetColorMap();
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
#ifdef USE_IMG2
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
nscoord aDWidth, nscoord aDHeight);
#endif
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
nsRect &aSrcRect,
nsRect &aTileRect);
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
const nsRect &aTileRect);
virtual void ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth,
nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized();
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
virtual PRUint8* GetAlphaBits();
virtual PRInt32 GetAlphaWidth();
virtual PRInt32 GetAlphaHeight();
virtual PRInt32 GetAlphaLineStride();
virtual nsIImage* DuplicateImage();
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
virtual PRInt32 GetAlphaLevel();
/**
* 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);}
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY);
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
private:
/**
* Calculate the amount of memory needed for the initialization of the image
*/
void ComputeMetrics() {
mRowBytes = (mWidth * mDepth) >> 5;
if (((PRUint32)mWidth * mDepth) & 0x1F)
mRowBytes++;
mRowBytes <<= 2;
mSizeImage = mRowBytes * mHeight;
};
void ComputePaletteSize(PRIntn nBitCount);
protected:
void CreateImage(nsDrawingSurface aSurface);
nsresult BuildImage(nsDrawingSurface aDrawingSurface);
private:
BBitmap *mImage;
PRBool mStaticImage;
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mDepth; // bits per pixel
PRInt32 mRowBytes;
PRUint8 *mImageBits;
PRUint8 *mConvertedBits;
PRInt32 mSizeImage;
PRBool mIsTopToBottom;
PRInt8 mNumBytesPixel;
PRInt32 mNaturalWidth;
PRInt32 mNaturalHeight;
PRInt32 mDecodedX1; //Keeps track of what part of image
PRInt32 mDecodedY1; // has been decoded.
PRInt32 mDecodedX2;
PRInt32 mDecodedY2;
// alpha layer members
PRUint8 *mAlphaBits;
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mAlphaRowBytes; // alpha bytes per row
PRInt16 mAlphaWidth; // alpha layer width
PRInt16 mAlphaHeight; // alpha layer height
nsPoint mLocation; // alpha mask location
PRUint8 mFlags; // flags set by ImageUpdated
};
#endif

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Paul Ashford <arougthopher@lizardland.net>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPrintOptionsBeOS.h"
/** ---------------------------------------------------
* See documentation in nsPrintOptionsWin.h
* @update 6/21/00 dwc
*/
nsPrintOptionsBeOS::nsPrintOptionsBeOS()
{
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
nsPrintOptionsBeOS::~nsPrintOptionsBeOS()
{
}

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Paul Ashford <arougthopher@lizardland.net>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPrintOptionsBeOS_h__
#define nsPrintOptionsBeOS_h__
#include "nsPrintOptionsImpl.h"
//*****************************************************************************
//*** nsPrintOptions
//*****************************************************************************
class nsPrintOptionsBeOS : public nsPrintOptions
{
public:
nsPrintOptionsBeOS();
virtual ~nsPrintOptionsBeOS();
};
#endif /* nsPrintOptions_h__ */

View File

@@ -1,91 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#ifndef nsPrintdBeOS_h___
#define nsPrintdBeOS_h___
#include <limits.h>
PR_BEGIN_EXTERN_C
/* stolen from nsPostScriptObj.h. needs to be put somewhere else that
both ps and gtk can see easily */
#ifndef NS_LEGAL_SIZE
#define NS_LETTER_SIZE 0
#define NS_LEGAL_SIZE 1
#define NS_EXECUTIVE_SIZE 2
#define NS_A4_SIZE 3
#define NS_A3_SIZE 4
#define NS_PORTRAIT 0
#define NS_LANDSCAPE 1
#endif
#ifndef PATH_MAX
#ifdef _POSIX_PATH_MAX
#define PATH_MAX _POSIX_PATH_MAX
#else
#define PATH_MAX 256
#endif
#endif
typedef struct beosprdata {
PRBool toPrinter; /* If PR_TRUE, print to printer */
PRBool fpf; /* If PR_TRUE, first page first */
PRBool grayscale; /* If PR_TRUE, print grayscale */
int size; /* Paper size e.g., SizeLetter */
int orientation; /* Page orientation, e.g. portrait */
char command[ PATH_MAX ]; /* Print command e.g., lpr */
char path[ PATH_MAX ]; /* If toPrinter = PR_FALSE, dest file */
char printer[256]; /* Printer name */
int copies; /* number of copies */
PRBool cancel; /* If PR_TRUE, user cancelled */
float left; /* left margin */
float right; /* right margin */
float top; /* top margin */
float bottom; /* bottom margin */
} BeOSPrData;
//void BeOSPrDialog(UnixPrData *prData);
PR_END_EXTERN_C
#endif /* !defined(nsPrintdBeOS_h___) */

View File

@@ -1,264 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <Region.h>
#include "nsRegionBeOS.h"
#include "prmem.h"
#ifdef DEBUG_REGIONS
static int nRegions;
#endif
static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
nsRegionBeOS :: nsRegionBeOS()
{
NS_INIT_REFCNT();
#ifdef DEBUG_REGIONS
++nRegions;
printf("REGIONS+ = %i\n", nRegions);
#endif
mRegion.MakeEmpty();
mRegionType = eRegionComplexity_empty;
}
nsRegionBeOS :: ~nsRegionBeOS()
{
#ifdef DEBUG_REGIONS
--nRegions;
printf("REGIONS- = %i\n", nRegions);
#endif
mRegion.MakeEmpty();
}
NS_IMPL_ISUPPORTS1(nsRegionBeOS, nsIRegion)
nsresult nsRegionBeOS :: Init(void)
{
mRegion.MakeEmpty();
mRegionType = eRegionComplexity_empty;
return NS_OK;
}
void nsRegionBeOS :: SetTo(const nsIRegion &aRegion)
{
Init();
nsRegionBeOS *pRegion = (nsRegionBeOS *)&aRegion;
mRegion = pRegion->mRegion;
SetRegionType();
}
void nsRegionBeOS :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
Init();
mRegion.Set(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
SetRegionType();
}
void nsRegionBeOS :: Intersect(const nsIRegion &aRegion)
{
nsRegionBeOS *pRegion = (nsRegionBeOS*)&aRegion;
mRegion.IntersectWith(&pRegion->mRegion);
SetRegionType();
}
void nsRegionBeOS :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
BRegion tRegion;
tRegion.Set( BRect( aX, aY, aX + aWidth - 1, aY + aHeight - 1 ) );
mRegion.IntersectWith(&tRegion);
SetRegionType();
}
void nsRegionBeOS :: Union(const nsIRegion &aRegion)
{
nsRegionBeOS *pRegion = (nsRegionBeOS*)&aRegion;
mRegion.Include(&pRegion->mRegion);
SetRegionType();
}
void nsRegionBeOS :: Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
mRegion.Include(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
SetRegionType();
}
void nsRegionBeOS :: Subtract(const nsIRegion &aRegion)
{
nsRegionBeOS *pRegion = (nsRegionBeOS*)&aRegion;
mRegion.Exclude(&pRegion->mRegion);
SetRegionType();
}
void nsRegionBeOS :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
mRegion.Exclude(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
SetRegionType();
}
PRBool nsRegionBeOS :: IsEmpty(void)
{
if( mRegionType == eRegionComplexity_empty )
return PR_TRUE;
return PR_FALSE;
}
PRBool nsRegionBeOS :: IsEqual(const nsIRegion &aRegion)
{
#ifdef DEBUG
printf(" - nsRegionBeOS :: IsEqual not implemented!\n");
#endif
return PR_FALSE;
}
void nsRegionBeOS :: GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
{
if( mRegion.CountRects() ) {
BRect rect = mRegion.Frame();
*aX = nscoord(rect.left);
*aY = nscoord(rect.top);
*aWidth = nscoord(rect.Width()+1);
*aHeight = nscoord(rect.Height()+1);
}
else
{
*aX = *aY = *aWidth = *aHeight = 0;
}
}
void nsRegionBeOS :: Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
mRegion.OffsetBy( aXOffset, aYOffset );
}
void nsRegionBeOS :: SetRegionType(void)
{
if(mRegion.CountRects() == 1)
mRegionType = eRegionComplexity_rect ;
else if(mRegion.CountRects() > 1)
mRegionType = eRegionComplexity_complex ;
else
mRegionType = eRegionComplexity_empty;
}
PRBool nsRegionBeOS :: ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
return mRegion.Intersects(BRect(aX, aY, aX + aWidth - 1, aY + aHeight - 1));
}
NS_IMETHODIMP nsRegionBeOS :: GetRects(nsRegionRectSet **aRects)
{
nsRegionRectSet *rects;
int nbox;
nsRegionRect *rect;
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
//code lifted from old xfe. MMP
nbox = mRegion.CountRects();
rects = *aRects;
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32)nbox))
{
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 1)));
if(nsnull == buf)
{
if(nsnull != rects)
rects->mNumRects = 0;
return NS_OK;
}
rects = (nsRegionRectSet *)buf;
rects->mRectsLen = nbox;
}
rects->mNumRects = nbox;
rects->mArea = 0;
rect = &rects->mRects[0];
for(int32 i = 0; i < nbox; i++)
{
BRect r = mRegion.RectAt(i);
rect->x = nscoord(r.left);
rect->width = nscoord(r.right - r.left + 1);
rect->y = nscoord(r.top);
rect->height = nscoord(r.bottom - r.top + 1);
rects->mArea += rect->width * rect->height;
rect++;
}
*aRects = rects;
return NS_OK;
}
NS_IMETHODIMP nsRegionBeOS :: FreeRects(nsRegionRectSet *aRects)
{
if(nsnull != aRects)
PR_Free((void *)aRects);
return NS_OK;
}
NS_IMETHODIMP nsRegionBeOS :: GetNativeRegion(void *&aRegion) const
{
aRegion = (void *)&mRegion;
return NS_OK;
}
NS_IMETHODIMP nsRegionBeOS :: GetRegionComplexity(nsRegionComplexity &aComplexity) const
{
aComplexity = mRegionType;
return NS_OK;
}

View File

@@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRegionBeOS_h___
#define nsRegionBeOS_h___
#include "nsIRegion.h"
#include <Region.h>
class nsRegionBeOS : public nsIRegion
{
public:
nsRegionBeOS();
virtual ~nsRegionBeOS();
NS_DECL_ISUPPORTS
virtual nsresult Init();
virtual void SetTo(const nsIRegion &aRegion);
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void SetTo(const nsRegionBeOS *aRegion);
virtual void Intersect(const nsIRegion &aRegion);
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union(const nsIRegion &aRegion);
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract(const nsIRegion &aRegion);
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty(void);
virtual PRBool IsEqual(const nsIRegion &aRegion);
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
protected:
void SetRegionType(void);
private:
BRegion mRegion;
nsRegionComplexity mRegionType;
};
#endif // nsRegionBeOS_h___

File diff suppressed because it is too large Load Diff

View File

@@ -1,246 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRenderingContextBeOS_h___
#define nsRenderingContextBeOS_h___
#include "nsRenderingContextImpl.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 "nsIImage.h"
#include "nsIDeviceContext.h"
#include "nsVoidArray.h"
#include "nsGfxCIID.h"
#include "nsDrawingSurfaceBeOS.h"
#include "nsRegionBeOS.h"
#define USE_NATIVE_TILING 1
class nsRenderingContextBeOS : public nsRenderingContextImpl
{
public:
nsRenderingContextBeOS();
virtual ~nsRenderingContextBeOS();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface 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(nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipEmpty);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
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);
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(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawStdLine(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 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 DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
#ifdef USE_NATIVE_TILING
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
nscoord aSrcYOffset, const nsRect &aTileRect);
#endif
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
//locals
NS_IMETHOD CommonInit();
void CreateClipRegion() {
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
if (mClipRegion)
return;
PRUint32 w, h;
mSurface->GetSize(&w, &h);
mClipRegion = do_CreateInstance(kRegionCID);
if (mClipRegion) {
mClipRegion->Init();
mClipRegion->SetTo(0,0,w,h);
}
}
protected:
nsDrawingSurfaceBeOS *mOffscreenSurface;
nsDrawingSurfaceBeOS *mSurface;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsCOMPtr<nsIRegion> mClipRegion;
float mP2T;
// graphic state stack (GraphicsState)
nsVoidArray *mStateCache;
BView *mView;
PRUint8 *mGammaTable;
nscolor mCurrentColor;
BFont *mCurrentFont;
nsLineStyle mCurrentLineStyle;
void UpdateView();
// ConditionRect is used to fix coordinate overflow problems for
// rectangles after they are transformed to screen coordinates
void ConditionRect(nscoord &x, nscoord &y, nscoord &w, nscoord &h) {
if ( y < -32766 ) {
y = -32766;
}
if ( y + h > 32766 ) {
h = 32766 - y;
}
if ( x < -32766 ) {
x = -32766;
}
if ( x + w > 32766 ) {
w = 32766 - x;
}
}
};
#endif /* nsRenderingContextBeOS_h___ */

View File

@@ -1,137 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenBeOS.h"
#include <Screen.h>
nsScreenBeOS :: nsScreenBeOS ( )
{
NS_INIT_REFCNT();
// 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.
}
nsScreenBeOS :: ~nsScreenBeOS()
{
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenBeOS, nsIScreen)
NS_IMETHODIMP
nsScreenBeOS :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
BScreen screen;
*outTop = 0;
*outLeft = 0;
*outWidth = PRInt32(screen.Frame().Width()+1);
*outHeight = PRInt32(screen.Frame().Height()+1);
return NS_OK;
} // GetRect
NS_IMETHODIMP
nsScreenBeOS :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
BScreen screen;
*outTop = 0;
*outLeft = 0;
*outWidth = PRInt32(screen.Frame().Width()+1);
*outHeight = PRInt32(screen.Frame().Height()+1);
return NS_OK;
} // GetAvailRect
NS_IMETHODIMP
nsScreenBeOS :: GetPixelDepth(PRInt32 *aPixelDepth)
{
BScreen screen;
color_space depth;
PRInt32 pixelDepth;
depth = screen.ColorSpace();
switch(depth)
{
case B_CMAP8:
pixelDepth = 8;
break;
case B_RGB32:
pixelDepth = 32;
break;
case B_RGB15:
pixelDepth = 15;
break;
case B_RGB16:
pixelDepth = 16;
break;
default:
#ifdef DEBUG
printf("FIXME: Please add this screen depth to the code nsScreenBeOS.cpp\n");
#endif
pixelDepth = 32;
break;
}
*aPixelDepth = pixelDepth;
return NS_OK;
} // GetPixelDepth
NS_IMETHODIMP
nsScreenBeOS :: GetColorDepth(PRInt32 *aColorDepth)
{
return GetPixelDepth ( aColorDepth );
} // GetColorDepth

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenBeOS_h___
#define nsScreenBeOS_h___
#include "nsIScreen.h"
//------------------------------------------------------------------------
class nsScreenBeOS : public nsIScreen
{
public:
nsScreenBeOS ( );
virtual ~nsScreenBeOS();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
private:
};
#endif // nsScreenBeOS_h___

View File

@@ -1,128 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenManagerBeOS.h"
#include "nsScreenBeOS.h"
nsScreenManagerBeOS :: nsScreenManagerBeOS ( )
{
NS_INIT_REFCNT();
// 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.
}
nsScreenManagerBeOS :: ~nsScreenManagerBeOS()
{
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenManagerBeOS, 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*
nsScreenManagerBeOS :: CreateNewScreenObject ( )
{
nsIScreen* retval = nsnull;
if ( !mCachedMainScreen )
mCachedMainScreen = new nsScreenBeOS ( );
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
nsScreenManagerBeOS :: 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
nsScreenManagerBeOS :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
{
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
return NS_OK;
} // GetPrimaryScreen
//
// GetNumberOfScreens
//
// Returns how many physical screens are available.
//
NS_IMETHODIMP
nsScreenManagerBeOS :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
{
*aNumberOfScreens = 1;
return NS_OK;
} // GetNumberOfScreens

View File

@@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenManagerBeOS_h___
#define nsScreenManagerBeOS_h___
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsCOMPtr.h"
//------------------------------------------------------------------------
class nsScreenManagerBeOS : public nsIScreenManager
{
public:
nsScreenManagerBeOS ( );
virtual ~nsScreenManagerBeOS();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
nsIScreen* CreateNewScreenObject ( ) ;
// cache the primary screen object to avoid memory allocation every time
nsCOMPtr<nsIScreen> mCachedMainScreen;
};
#endif // nsScreenManagerBeOS_h___

View File

@@ -1,161 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx
LIBRARY_NAME = gfx_gtk
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsGfxGTKModule
REQUIRES = xpcom \
string \
widget \
view \
util \
dom \
pref \
uconv \
unicharutil \
windowwatcher \
locale \
content \
layout \
necko \
$(NULL)
# Sun's Complex Text Layout support
ifdef SUNCTL
REQUIRES += ctl
endif
#NATIVE_THEME_SUPPORT = 1
CSRCS = nsPrintdGTK.c
ifdef NATIVE_THEME_SUPPORT
CSRCS += gtkdrawing.c
endif
# Code shared between GTK+, Xlib and Xprint gfx modules
X11SHARED_LCPPSRCS = \
nsAntiAliasedGlyph.cpp \
nsX11AlphaBlend.cpp \
nsXFontAAScaledBitmap.cpp \
nsXFontNormal.cpp \
$(NULL)
CPPSRCS = \
$(X11SHARED_LCPPSRCS) \
nsDeviceContextGTK.cpp \
nsDeviceContextSpecFactoryG.cpp \
nsDeviceContextSpecG.cpp \
nsDrawingSurfaceGTK.cpp \
nsFontMetricsGTK.cpp \
nsGfxFactoryGTK.cpp \
nsGraphicsStateGTK.cpp \
nsImageGTK.cpp \
nsRegionGTK.cpp \
nsGCCache.cpp \
nsRenderingContextGTK.cpp \
nsScreenGtk.cpp \
nsScreenManagerGtk.cpp \
nsPrintOptionsGTK.cpp \
$(NULL)
ifdef NATIVE_THEME_SUPPORT
CPPSRCS += nsNativeThemeGTK.cpp
endif
# If not primary toolkit, install in secondary path
ifneq (gtk,$(MOZ_GFX_TOOLKIT))
INACTIVE_COMPONENT = 1
endif
ifdef MOZ_ENABLE_XPRINT
XPU_LCSRCS = xprintutil.c
CSRCS += $(XPU_LCSRCS)
endif
GARBAGE += $(X11SHARED_LCPPSRCS) $(XPU_LCSRCS) $(wildcard *.$(OBJ_SUFFIX))
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
CXXFLAGS += $(MOZ_GTK_CFLAGS)
CFLAGS += $(MOZ_GTK_CFLAGS)
ifdef MOZ_ENABLE_XINERAMA
GFX_XINERAMA_LIBS += $(MOZ_XINERAMA_LIBS)
endif
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
-lgkgfx \
$(GFX_XINERAMA_LIBS) \
-lgtksuperwin \
$(MOZ_JS_LIBS) \
$(NULL)
DEFINES += -D_IMPL_NS_GFXNONXP
ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif
ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES += -D_TIME_H=1
endif
endif
ifdef MOZ_ENABLE_XPRINT
DEFINES += -DUSE_XPRINT -DUSE_MOZILLA_TYPES
INCLUDES += -I$(srcdir)/../xprint
EXTRA_DSO_LDOPTS += $(MOZ_XPRINT_LDFLAGS)
endif
ifdef NATIVE_THEME_SUPPORT
DEFINES += -DNATIVE_THEME_SUPPORT
endif
LOCAL_INCLUDES = \
-I$(srcdir)/. \
-I$(srcdir)/.. \
-I$(srcdir)/../x11shared \
$(NULL)
ifdef MOZ_ENABLE_XPRINT
export:: $(addprefix $(srcdir)/../xprint/,$(XPU_LCSRCS)) $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
$(INSTALL) $^ .
else
export:: $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
$(INSTALL) $^ .
endif

View File

@@ -1,237 +0,0 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@netscape.com> (Original Author)
*
* 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 ***** */
/*
* This file contains painting functions for each of the gtk widgets.
* Adapted from the gtk+ 1.2.10 source.
*/
#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include "gtkdrawing.h"
extern GtkWidget* gButtonWidget;
extern GtkWidget* gCheckboxWidget;
extern GtkWidget* gScrollbarWidget;
extern GtkWidget* gGripperWidget;
GtkStateType
ConvertGtkState(GtkWidgetState* aState)
{
if (aState->active)
return GTK_STATE_ACTIVE;
else if (aState->disabled)
return GTK_STATE_INSENSITIVE;
else if (aState->inHover)
return GTK_STATE_PRELIGHT;
else
return GTK_STATE_NORMAL;
}
void
moz_gtk_button_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* buttonRect, GdkRectangle* clipRect,
GtkWidgetState* buttonState, GtkReliefStyle relief)
{
GtkShadowType shadow_type;
gint default_spacing = 7; /* xxx fix me */
GtkStateType button_state = ConvertGtkState(buttonState);
gint x = buttonRect->x, y=buttonRect->y, width=buttonRect->width, height=buttonRect->height;
if (((GdkWindowPrivate*)window)->mapped) {
gdk_window_set_back_pixmap(window, NULL, TRUE);
gdk_window_clear_area(window, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
}
gtk_widget_set_state(gButtonWidget, button_state);
if (buttonState->isDefault)
gtk_paint_box(style, window, GTK_STATE_NORMAL, GTK_SHADOW_IN,
clipRect, gButtonWidget, "buttondefault", x, y, width, height);
if (buttonState->canDefault) {
x += style->klass->xthickness;
y += style->klass->ythickness;
width -= 2 * x + default_spacing;
height -= 2 * y + default_spacing;
x += (1 + default_spacing) / 2;
y += (1 + default_spacing) / 2;
}
if (buttonState->focused) {
x += 1;
y += 1;
width -= 2;
height -= 2;
}
shadow_type = (buttonState->active) ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
if (relief != GTK_RELIEF_NONE || (button_state != GTK_STATE_NORMAL &&
button_state != GTK_STATE_INSENSITIVE))
gtk_paint_box(style, window, button_state, shadow_type, clipRect,
gButtonWidget, "button", x, y, width, height);
if (buttonState->focused) {
x -= 1;
y -= 1;
width += 2;
height += 2;
gtk_paint_focus(style, window, clipRect, gButtonWidget, "button",
x, y, width - 1, height - 1);
}
}
void
moz_gtk_check_button_draw_indicator(GdkWindow* window, GtkStyle* style,
GdkRectangle* boxRect, GdkRectangle* clipRect,
GtkToggleButtonState* aState)
{
GtkStateType state_type;
GtkShadowType shadow_type;
gint indicator_size = 10;
gint indicator_spacing = 2;
GtkWidgetState* wState = (GtkWidgetState*) aState;
gint x, y, width, height;
/* XXX get indicator size/spacing properties
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
*/
state_type = ConvertGtkState(wState);
if (state_type != GTK_STATE_NORMAL &&
state_type != GTK_STATE_PRELIGHT)
state_type = GTK_STATE_NORMAL;
if (state_type != GTK_STATE_NORMAL) /* this is for drawing e.g. a prelight box */
gtk_paint_flat_box (style, window, state_type,
GTK_SHADOW_ETCHED_OUT,
clipRect, gCheckboxWidget, "checkbutton",
boxRect->x, boxRect->y,
boxRect->width, boxRect->height);
x = boxRect->x + indicator_spacing;
y = boxRect->y + (boxRect->height - indicator_size) / 2;
width = indicator_size;
height = indicator_size;
if (aState->selected) {
state_type = GTK_STATE_ACTIVE;
shadow_type = GTK_SHADOW_IN;
}
else {
shadow_type = GTK_SHADOW_OUT;
state_type = ConvertGtkState(wState);
}
gtk_paint_check (style, window,
state_type, shadow_type,
clipRect, gCheckboxWidget, "checkbutton",
x + 1, y + 1, width, height);
}
void
moz_gtk_checkbox_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* boxRect, GdkRectangle* clipRect,
GtkToggleButtonState* aState)
{
moz_gtk_check_button_draw_indicator(window, style, boxRect, clipRect, aState);
if (((GtkWidgetState*)aState)->focused)
gtk_paint_focus (style, window,
clipRect, gCheckboxWidget, "checkbutton",
boxRect->x, boxRect->y, boxRect->width - 1, boxRect->height - 1);
}
void
moz_gtk_scrollbar_button_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* arrowRect, GdkRectangle* clipRect,
GtkWidgetState* state, GtkArrowType arrowType)
{
GtkStateType state_type = ConvertGtkState(state);
GtkShadowType shadow_type = (state->active) ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
gtk_paint_arrow(style, window, state_type, shadow_type, clipRect,
gScrollbarWidget, (arrowType < 2) ? "vscrollbar" : "hscrollbar",
arrowType, TRUE,
arrowRect->x, arrowRect->y, arrowRect->width, arrowRect->height);
}
void
moz_gtk_scrollbar_trough_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* troughRect, GdkRectangle* clipRect,
GtkWidgetState* state)
{
gtk_style_apply_default_background(style, window, TRUE, GTK_STATE_ACTIVE,
clipRect, troughRect->x, troughRect->y,
troughRect->width, troughRect->height);
gtk_paint_box(style, window, GTK_STATE_ACTIVE, GTK_SHADOW_IN,
clipRect, gScrollbarWidget, "trough", troughRect->x,
troughRect->y, troughRect->width, troughRect->height);
if (state->focused)
gtk_paint_focus(style, window, clipRect, gScrollbarWidget, "trough",
troughRect->x, troughRect->y, troughRect->width,
troughRect->height);
}
void
moz_gtk_scrollbar_thumb_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* thumbRect, GdkRectangle* clipRect,
GtkWidgetState* state)
{
GtkStateType state_type = state->inHover ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
gtk_paint_box(style, window, state_type, GTK_SHADOW_OUT, clipRect,
gScrollbarWidget, "slider", thumbRect->x, thumbRect->y,
thumbRect->width, thumbRect->height);
}
void
moz_gtk_gripper_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* clipRect, GtkWidgetState* state)
{
GtkStateType state_type = ConvertGtkState(state);
GtkShadowType shadow_type = GTK_HANDLE_BOX(gGripperWidget)->shadow_type;
gtk_paint_box(style, window, state_type, shadow_type, clipRect,
gGripperWidget, "handlebox_bin", rect->x, rect->y,
rect->width, rect->height);
}

View File

@@ -1,103 +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) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@netscape.com> (Original Author)
*
* 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 _GTK_DRAWING_H_
#define _GTK_DRAWING_H_
#include <gdk/gdk.h>
#include <gtk/gtkstyle.h>
#include "prtypes.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct {
PRPackedBool active;
PRPackedBool focused;
PRPackedBool inHover;
PRPackedBool disabled;
PRPackedBool isDefault;
PRPackedBool canDefault;
} GtkWidgetState;
typedef struct {
GtkWidgetState wState;
PRPackedBool selected;
} GtkToggleButtonState;
void
moz_gtk_button_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* buttonRect, GdkRectangle* clipRect,
GtkWidgetState* buttonState, GtkReliefStyle relief);
void
moz_gtk_checkbox_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* boxRect, GdkRectangle* clipRect,
GtkToggleButtonState* aState);
void
moz_gtk_radio_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* boxRect, GdkRectangle* clipRect,
GtkToggleButtonState* aState);
void
moz_gtk_scrollbar_button_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* arrowRect, GdkRectangle* clipRect,
GtkWidgetState* state, GtkArrowType type);
void
moz_gtk_scrollbar_trough_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* troughRect, GdkRectangle* clipRect,
GtkWidgetState* state);
void
moz_gtk_scrollbar_thumb_paint(GdkWindow* window, GtkStyle* style,
GdkRectangle* thumbRect, GdkRectangle* clipRect,
GtkWidgetState* state);
void
moz_gtk_gripper_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
GdkRectangle* clipRect, GtkWidgetState* state);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@@ -1,836 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:cindent:ts=2:et:sw=2:
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <math.h>
#include "nspr.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsCRT.h"
#include "nsDeviceContextGTK.h"
#include "nsFontMetricsGTK.h"
#include "nsGfxCIID.h"
#include "nsGfxPSCID.h"
#include "nsIDeviceContextPS.h"
#ifdef USE_XPRINT
#include "nsGfxXPrintCID.h"
#include "nsIDeviceContextXPrint.h"
#endif /* USE_XPRINT */
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
#include "nsDeviceContextSpecG.h"
#define NS_TO_GDK_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
#define GDK_COLOR_TO_NS_RGB(c) \
((nscolor) NS_RGB(c.red, c.green, c.blue))
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#define GDK_DEFAULT_FONT1 "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"
#define GDK_DEFAULT_FONT2 "-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*"
extern GdkFont *default_font;
/**
* A singleton instance of nsSystemFontsGTK is created by the first
* device context and destroyed by the module destructor.
*/
class nsSystemFontsGTK {
public:
nsSystemFontsGTK(float aPixelsToTwips);
const nsFont& GetDefaultFont() { return mDefaultFont; }
const nsFont& GetMenuFont() { return mMenuFont; }
const nsFont& GetFieldFont() { return mFieldFont; }
const nsFont& GetButtonFont() { return mButtonFont; }
private:
nsresult GetSystemFontInfo(GdkFont* iFont, nsFont* aFont,
float aPixelsToTwips) const;
/*
* The following system font constants exist:
*
* css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27
* eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu,
* eSystemFont_MessageBox, eSystemFont_SmallCaption,
* eSystemFont_StatusBar,
* // css3
* eSystemFont_Window, eSystemFont_Document,
* eSystemFont_Workspace, eSystemFont_Desktop,
* eSystemFont_Info, eSystemFont_Dialog,
* eSystemFont_Button, eSystemFont_PullDownMenu,
* eSystemFont_List, eSystemFont_Field,
* // moz
* eSystemFont_Tooltips, eSystemFont_Widget
*/
nsFont mDefaultFont;
nsFont mButtonFont;
nsFont mFieldFont;
nsFont mMenuFont;
};
nscoord nsDeviceContextGTK::mDpi = 96;
static nsSystemFontsGTK *gSystemFonts = nsnull;
nsDeviceContextGTK::nsDeviceContextGTK()
: DeviceContextImpl()
{
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mDepth = 0 ;
mNumCells = 0;
mWidthFloat = 0.0f;
mHeightFloat = 0.0f;
mWidth = -1;
mHeight = -1;
mDeviceWindow = nsnull;
}
nsDeviceContextGTK::~nsDeviceContextGTK()
{
nsresult rv;
nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv);
if (NS_SUCCEEDED(rv)) {
prefs->UnregisterCallback("browser.display.screen_resolution",
prefChanged, (void *)this);
}
}
/* static */ void nsDeviceContextGTK::Shutdown()
{
if (gSystemFonts) {
delete gSystemFonts;
gSystemFonts = nsnull;
}
}
NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
{
GtkRequisition req;
GtkWidget *sb;
// get the screen object and its width/height
// XXXRight now this will only get the primary monitor.
if (!mScreenManager)
mScreenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
if (!mScreenManager) {
return NS_ERROR_FAILURE;
}
if (aNativeWidget) {
// superwin?
if (GDK_IS_SUPERWIN(aNativeWidget)) {
mDeviceWindow = GDK_SUPERWIN(aNativeWidget)->shell_window;
}
// gtk widget?
else if (GTK_IS_WIDGET(aNativeWidget)) {
mDeviceWindow = GTK_WIDGET(aNativeWidget)->window;
}
// must be a bin_window
else {
mDeviceWindow = NS_STATIC_CAST(GdkWindow *, aNativeWidget);
}
}
nsCOMPtr<nsIScreen> screen;
mScreenManager->GetPrimaryScreen ( getter_AddRefs(screen) );
if ( screen ) {
PRInt32 x, y, width, height, depth;
screen->GetAvailRect ( &x, &y, &width, &height );
screen->GetPixelDepth ( &depth );
mWidthFloat = float(width);
mHeightFloat = float(height);
mDepth = NS_STATIC_CAST ( PRUint32, depth );
}
static int initialized = 0;
PRInt32 prefVal = -1;
if (!initialized) {
initialized = 1;
// Set prefVal the value of the preference
// "browser.display.screen_resolution"
// 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(kPrefCID, &res));
if (NS_SUCCEEDED(res) && prefs) {
res = prefs->GetIntPref("browser.display.screen_resolution", &prefVal);
if (NS_FAILED(res)) {
prefVal = -1;
}
prefs->RegisterCallback("browser.display.screen_resolution", prefChanged,
(void *)this);
}
SetDPI(prefVal);
} else {
SetDPI(mDpi); // to setup p2t and t2p
}
sb = gtk_vscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarWidth = req.width;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
sb = gtk_hscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarHeight = req.height;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
#ifdef DEBUG
static PRBool once = PR_TRUE;
if (once) {
printf("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n", mDpi, mTwipsToPixels, mPixelsToTwips,mDepth);
once = PR_FALSE;
}
#endif
DeviceContextImpl::CommonInit();
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::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
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceGTK *surf;
GtkWidget *w;
w = (GtkWidget*)mWidget;
// to call init for this, we need to have a valid nsDrawingSurfaceGTK created
pContext = new nsRenderingContextGTK();
if (nsnull != pContext)
{
NS_ADDREF(pContext);
// create the nsDrawingSurfaceGTK
surf = new nsDrawingSurfaceGTK();
if (surf && w)
{
GdkDrawable *gwin = nsnull;
GdkDrawable *win = nsnull;
// FIXME
if (GTK_IS_LAYOUT(w))
gwin = (GdkDrawable*)GTK_LAYOUT(w)->bin_window;
else
gwin = (GdkDrawable*)(w)->window;
// window might not be realized... ugh
if (gwin)
gdk_window_ref(gwin);
else
win = gdk_pixmap_new(nsnull,
w->allocation.width,
w->allocation.height,
gdk_rgb_get_visual()->depth);
GdkGC *gc = gdk_gc_new(win);
// init the nsDrawingSurfaceGTK
rv = surf->Init(win,gc);
if (NS_OK == rv)
// Init the nsRenderingContextGTK
rv = pContext->Init(this, surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv)
{
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
//XXX it is very critical that this not lie!! MMP
// read the comments in the mac code for this
aSupportsWidgets = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
aWidth = mScrollbarWidth * mPixelsToTwips;
aHeight = mScrollbarHeight * mPixelsToTwips;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
{
nsresult status = NS_OK;
if (!gSystemFonts) {
gSystemFonts = new nsSystemFontsGTK(mPixelsToTwips);
}
switch (aID) {
case eSystemFont_Menu: // css2
case eSystemFont_PullDownMenu: // css3
*aFont = gSystemFonts->GetMenuFont();
break;
case eSystemFont_Field: // css3
case eSystemFont_List: // css3
*aFont = gSystemFonts->GetFieldFont();
break;
case eSystemFont_Button: // css3
*aFont = gSystemFonts->GetButtonFont();
break;
case eSystemFont_Caption: // css2
case eSystemFont_Icon: // css2
case eSystemFont_MessageBox: // css2
case eSystemFont_SmallCaption: // css2
case eSystemFont_StatusBar: // css2
case eSystemFont_Window: // css3
case eSystemFont_Document: // css3
case eSystemFont_Workspace: // css3
case eSystemFont_Desktop: // css3
case eSystemFont_Info: // css3
case eSystemFont_Dialog: // css3
case eSystemFont_Tooltips: // moz
case eSystemFont_Widget: // moz
*aFont = gSystemFonts->GetDefaultFont();
break;
}
return status;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDrawingSurface(nsIRenderingContext &aContext,
nsDrawingSurface &aSurface)
{
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::ConvertPixel(nscolor aColor,
PRUint32 & aPixel)
{
aPixel = ::gdk_rgb_xpixel_from_rgb (NS_TO_GDK_RGB(aColor));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::CheckFontExistence(const nsString& aFontName)
{
return nsFontMetricsGTK::FamilyExists(aFontName);
}
NS_IMETHODIMP nsDeviceContextGTK::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 (mWidth == -1)
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
if (mHeight == -1)
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
aWidth = mWidth;
aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetRect(nsRect &aRect)
{
// if we have an initialized widget for this device context, use it
// to try and get real screen coordinates.
if (mDeviceWindow) {
gint x, y, width, height, depth;
x = y = width = height = 0;
gdk_window_get_geometry(mDeviceWindow, &x, &y, &width, &height,
&depth);
gdk_window_get_origin(mDeviceWindow, &x, &y);
nsCOMPtr<nsIScreen> screen;
mScreenManager->ScreenForRect(x, y, width, height, getter_AddRefs(screen));
screen->GetRect(&aRect.x, &aRect.y, &aRect.width, &aRect.height);
aRect.x = NSToIntRound(mDevUnitsToAppUnits * aRect.x);
aRect.y = NSToIntRound(mDevUnitsToAppUnits * aRect.y);
aRect.width = NSToIntRound(mDevUnitsToAppUnits * aRect.width);
aRect.height = NSToIntRound(mDevUnitsToAppUnits * aRect.height);
}
else {
PRInt32 width, height;
GetDeviceSurfaceDimensions(width, height);
aRect.x = 0;
aRect.y = 0;
aRect.width = width;
aRect.height = height;
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetClientRect(nsRect &aRect)
{
// The client rect is never different from the standard rect on
// linux because we don't have the concept of the title bar.
return GetRect ( aRect );
}
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
nsresult rv;
PrintMethod method;
nsDeviceContextSpecGTK *spec = NS_STATIC_CAST(nsDeviceContextSpecGTK *, aDevice);
rv = spec->GetPrintMethod(method);
if (NS_FAILED(rv))
return rv;
#ifdef USE_XPRINT
if (method == pmXprint) { // XPRINT
static NS_DEFINE_CID(kCDeviceContextXp, NS_DEVICECONTEXTXP_CID);
nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context.");
if (NS_FAILED(rv))
return rv;
rv = dcxp->SetSpec(aDevice);
if (NS_FAILED(rv))
return rv;
rv = dcxp->InitDeviceContextXP((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
if (NS_FAILED(rv))
return rv;
rv = dcxp->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
return rv;
}
else
#endif /* USE_XPRINT */
if (method == pmPostScript) { // PostScript
// default/PS
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
// Create a Postscript device context
nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context.");
if (NS_FAILED(rv))
return rv;
rv = dcps->SetSpec(aDevice);
if (NS_FAILED(rv))
return rv;
rv = dcps->InitDeviceContextPS((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
if (NS_FAILED(rv))
return rv;
rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
return rv;
}
NS_WARNING("no print module created.");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(PRUnichar * aTitle)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndDocument(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::BeginPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDepth(PRUint32& aDepth)
{
aDepth = mDepth;
return NS_OK;
}
nsresult
nsDeviceContextGTK::SetDPI(PRInt32 aPrefDPI)
{
// Set OSVal to what the operating system thinks the logical resolution is.
float screenWidthIn = float(::gdk_screen_width_mm()) / 25.4f;
PRInt32 OSVal = NSToCoordRound(float(::gdk_screen_width()) / screenWidthIn);
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 nsDeviceContextGTK::prefChanged(const char *aPref, void *aClosure)
{
nsDeviceContextGTK *context = (nsDeviceContextGTK*)aClosure;
nsresult rv;
if (nsCRT::strcmp(aPref, "browser.display.screen_resolution")==0) {
PRInt32 dpi;
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &rv));
rv = prefs->GetIntPref(aPref, &dpi);
if (NS_SUCCEEDED(rv))
context->SetDPI(dpi);
// If this pref changes, we have to clear our cache of stored system
// fonts.
if (gSystemFonts) {
delete gSystemFonts;
gSystemFonts = nsnull;
}
}
return 0;
}
#define DEFAULT_TWIP_FONT_SIZE 240
nsSystemFontsGTK::nsSystemFontsGTK(float aPixelsToTwips)
: mDefaultFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, NS_FONT_DECORATION_NONE,
DEFAULT_TWIP_FONT_SIZE),
mButtonFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, NS_FONT_DECORATION_NONE,
DEFAULT_TWIP_FONT_SIZE),
mFieldFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, NS_FONT_DECORATION_NONE,
DEFAULT_TWIP_FONT_SIZE),
mMenuFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, NS_FONT_DECORATION_NONE,
DEFAULT_TWIP_FONT_SIZE)
{
/*
* Much of the widget creation code here is similar to the code in
* nsLookAndFeel::InitColors().
*/
// mDefaultFont
GtkWidget *label = gtk_label_new("M");
GtkWidget *parent = gtk_fixed_new();
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
gtk_container_add(GTK_CONTAINER(parent), label);
gtk_container_add(GTK_CONTAINER(window), parent);
gtk_widget_set_rc_style(parent);
gtk_widget_set_rc_style(label);
gtk_widget_realize(parent);
gtk_widget_realize(label);
GtkStyle *style = gtk_widget_get_style(label);
GetSystemFontInfo(style->font, &mDefaultFont, aPixelsToTwips);
gtk_widget_destroy(window); // no unref, windows are different
// mFieldFont
GtkWidget *entry = gtk_entry_new();
parent = gtk_fixed_new();
window = gtk_window_new(GTK_WINDOW_POPUP);
gtk_container_add(GTK_CONTAINER(parent), entry);
gtk_container_add(GTK_CONTAINER(window), parent);
gtk_widget_set_rc_style(entry);
gtk_widget_realize(entry);
style = gtk_widget_get_style(entry);
GetSystemFontInfo(style->font, &mFieldFont, aPixelsToTwips);
gtk_widget_destroy(window); // no unref, windows are different
// mMenuFont
GtkWidget *accel_label = gtk_accel_label_new("M");
GtkWidget *menuitem = gtk_menu_item_new();
GtkWidget *menu = gtk_menu_new();
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_set_rc_style(accel_label);
gtk_widget_set_rc_style(menu);
gtk_widget_realize(menu);
gtk_widget_realize(accel_label);
style = gtk_widget_get_style(accel_label);
GetSystemFontInfo(style->font, &mMenuFont, aPixelsToTwips);
gtk_widget_unref(menu);
// mButtonFont
parent = gtk_fixed_new();
GtkWidget *button = gtk_button_new();
label = gtk_label_new("M");
window = gtk_window_new(GTK_WINDOW_POPUP);
gtk_container_add(GTK_CONTAINER(button), label);
gtk_container_add(GTK_CONTAINER(parent), button);
gtk_container_add(GTK_CONTAINER(window), parent);
gtk_widget_set_rc_style(button);
gtk_widget_set_rc_style(label);
gtk_widget_realize(button);
gtk_widget_realize(label);
style = gtk_widget_get_style(label);
GetSystemFontInfo(style->font, &mButtonFont, aPixelsToTwips);
gtk_widget_destroy(window); // no unref, windows are different
}
#if 0 // debugging code to list the font properties
static void
ListFontProps(XFontStruct *aFont, Display *aDisplay)
{
printf("\n\n");
for (int i = 0, n = aFont->n_properties; i < n; ++i) {
XFontProp *prop = aFont->properties + i;
char *atomName = ::XGetAtomName(aDisplay, prop->name);
// 500 is just a guess
char *cardName = (prop->card32 > 0 && prop->card32 < 500)
? ::XGetAtomName(aDisplay, prop->card32)
: 0;
printf("%s : %ld (%s)\n", atomName, prop->card32, cardName?cardName:"");
::XFree(atomName);
if (cardName)
::XFree(cardName);
}
printf("\n\n");
}
#endif
static void
AppendFontName(XFontStruct* aFontStruct, nsString& aString, Display *aDisplay)
{
unsigned long pr = 0;
::XGetFontProperty(aFontStruct, XA_FAMILY_NAME, &pr);
if (!pr)
::XGetFontProperty(aFontStruct, XA_FULL_NAME, &pr);
if (pr) {
char *fontName = ::XGetAtomName(aDisplay, pr);
aString.AppendWithConversion(fontName);
::XFree(fontName);
}
}
static PRUint16
GetFontWeight(XFontStruct* aFontStruct, Display *aDisplay)
{
PRUint16 weight = NS_FONT_WEIGHT_NORMAL;
// WEIGHT_NAME seems more reliable than WEIGHT, where 10 can mean
// anything. Check both, and make it bold if either says so.
unsigned long pr = 0;
Atom weightName = ::XInternAtom(aDisplay, "WEIGHT_NAME", True);
if (weightName != None) {
::XGetFontProperty(aFontStruct, weightName, &pr);
if (pr) {
char *weightString = ::XGetAtomName(aDisplay, pr);
if (nsCRT::strcasecmp(weightString, "bold") == 0)
weight = NS_FONT_WEIGHT_BOLD;
::XFree(weightString);
}
}
pr = 0;
::XGetFontProperty(aFontStruct, XA_WEIGHT, &pr);
if ( pr > 10 )
weight = NS_FONT_WEIGHT_BOLD;
return weight;
}
static nscoord
GetFontSize(XFontStruct *aFontStruct, float aPixelsToTwips)
{
unsigned long pr = 0;
Atom pixelSizeAtom = ::XInternAtom(GDK_DISPLAY(), "PIXEL_SIZE", 0);
::XGetFontProperty(aFontStruct, pixelSizeAtom, &pr);
if (!pr)
return DEFAULT_TWIP_FONT_SIZE;
return NSIntPixelsToTwips(pr, aPixelsToTwips);
}
nsresult
nsSystemFontsGTK::GetSystemFontInfo(GdkFont* iFont, nsFont* aFont, float aPixelsToTwips) const
{
GdkFont *theFont = iFont;
aFont->style = NS_FONT_STYLE_NORMAL;
aFont->weight = NS_FONT_WEIGHT_NORMAL;
aFont->decorations = NS_FONT_DECORATION_NONE;
// do we have the default_font defined by GTK/GDK then
// we use it, if not then we load helvetica, if not then
// we load fixed font else we error out.
if (!theFont)
theFont = default_font; // GTK default font
if (!theFont)
theFont = ::gdk_font_load( GDK_DEFAULT_FONT1 );
if (!theFont)
theFont = ::gdk_font_load( GDK_DEFAULT_FONT2 );
if (!theFont)
return NS_ERROR_FAILURE;
Display *fontDisplay = GDK_FONT_XDISPLAY(theFont);
if (theFont->type == GDK_FONT_FONT) {
XFontStruct *fontStruct =
NS_STATIC_CAST(XFontStruct*, GDK_FONT_XFONT(theFont));
aFont->name.Truncate();
AppendFontName(fontStruct, aFont->name, fontDisplay);
aFont->weight = GetFontWeight(fontStruct, fontDisplay);
aFont->size = GetFontSize(fontStruct, aPixelsToTwips);
} else {
NS_ASSERTION(theFont->type == GDK_FONT_FONTSET,
"theFont->type can only have two values");
XFontSet fontSet = NS_REINTERPRET_CAST(XFontSet, GDK_FONT_XFONT(theFont));
XFontStruct **fontStructs;
char **fontNames;
int numFonts = ::XFontsOfFontSet(fontSet, &fontStructs, &fontNames);
if (numFonts == 0)
return NS_ERROR_FAILURE;
// Use the weight and size from the first font, but append all
// the names.
aFont->weight = GetFontWeight(*fontStructs, fontDisplay);
aFont->size = GetFontSize(*fontStructs, aPixelsToTwips);
nsString& fontName = aFont->name;
fontName.Truncate();
for (;;) {
AppendFontName(*fontStructs, fontName, fontDisplay);
++fontStructs;
--numFonts;
if (numFonts == 0)
break;
fontName.Append(NS_LITERAL_STRING(","));
}
}
return NS_OK;
}

View File

@@ -1,121 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextGTK_h___
#define nsDeviceContextGTK_h___
#include "nsDeviceContext.h"
#include "nsUnitConversion.h"
#include "nsIWidget.h"
#include "nsIView.h"
#include "nsIRenderingContext.h"
#include "nsRenderingContextGTK.h"
#include "nsIScreenManager.h"
#include "gdksuperwin.h"
class nsDeviceContextGTK : public DeviceContextImpl
{
public:
nsDeviceContextGTK();
virtual ~nsDeviceContextGTK();
static void Shutdown(); // to be called from module destructor
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aView,aContext));}
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aWidget,aContext));}
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
//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
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetClientRect(nsRect &aRect);
NS_IMETHOD GetRect(nsRect &aRect);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
NS_IMETHOD GetDepth(PRUint32& aDepth);
static int prefChanged(const char *aPref, void *aClosure);
protected:
nsresult SetDPI(PRInt32 aPrefDPI);
private:
PRUint32 mDepth;
PRBool mWriteable;
PRUint32 mNumCells;
PRInt16 mScrollbarHeight;
PRInt16 mScrollbarWidth;
static nscoord mDpi;
float mWidthFloat;
float mHeightFloat;
PRInt32 mWidth;
PRInt32 mHeight;
GdkWindow *mDeviceWindow;
nsCOMPtr<nsIScreenManager> mScreenManager;
nsresult GetSystemFontInfo(GdkFont* iFont, nsSystemFontID anID, nsFont* aFont) const;
};
#endif /* nsDeviceContextGTK_h___ */

View File

@@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecFactoryG.h"
#include "nsDeviceContextSpecG.h"
#include "nsGfxCIID.h"
#include "plstr.h"
/** -------------------------------------------------------
* Constructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: nsDeviceContextSpecFactoryGTK()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
* Destructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: ~nsDeviceContextSpecFactoryGTK()
{
}
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryGTK, nsIDeviceContextSpecFactory)
/** -------------------------------------------------------
* Initialize the device context spec factory
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
{
return NS_OK;
}
/** -------------------------------------------------------
* Get a device context specification
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv))
{
aNewSpec = devSpec;
NS_ADDREF(aNewSpec);
}
}
return rv;
}

View File

@@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecFactoryG_h___
#define nsDeviceContextSpecFactoryG_h___
#include "nsIDeviceContextSpecFactory.h"
#include "nsIDeviceContextSpec.h"
class nsDeviceContextSpecFactoryGTK : public nsIDeviceContextSpecFactory
{
public:
nsDeviceContextSpecFactoryGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(void);
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryGTK();
};
#endif

View File

@@ -1,645 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecG.h"
#include "nsReadableUtils.h"
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
#include "nsIDOMWindow.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsISupportsArray.h"
#ifdef USE_XPRINT
#include "xprintutil.h"
#endif /* USE_XPRINT */
//----------------------------------------------------------------------------------
// The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecG
// The PrinterEnumerator creates the printer info
// but the nsDeviceContextSpecG cleans it up
// If it gets created (via the Page Setup Dialog) but the user never prints anything
// then it will never be delete, so this class takes care of that.
class GlobalPrinters {
public:
static GlobalPrinters* GetInstance() { return &mGlobalPrinters; }
~GlobalPrinters() { FreeGlobalPrinters(); }
void FreeGlobalPrinters();
nsresult InitializeGlobalPrinters();
PRBool PrintersAreAllocated() { return mGlobalPrinterList != nsnull; }
PRInt32 GetNumPrinters() { return mGlobalNumPrinters; }
nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
protected:
GlobalPrinters() {}
static GlobalPrinters mGlobalPrinters;
static nsStringArray* mGlobalPrinterList;
static int mGlobalNumPrinters;
};
//---------------
// static members
GlobalPrinters GlobalPrinters::mGlobalPrinters;
nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
int GlobalPrinters::mGlobalNumPrinters = 0;
//---------------
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecGTK
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
* Destroy the nsDeviceContextSpecGTK
* @update dc 2/15/98
*/
nsDeviceContextSpecGTK :: ~nsDeviceContextSpecGTK()
{
}
#ifdef USE_XPRINT
NS_IMPL_ISUPPORTS3(nsDeviceContextSpecGTK,
nsIDeviceContextSpec,
nsIDeviceContextSpecPS,
nsIDeviceContextSpecXp)
#else
NS_IMPL_ISUPPORTS2(nsDeviceContextSpecGTK,
nsIDeviceContextSpec,
nsIDeviceContextSpecPS)
#endif /* USE_XPRINT */
static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
const char* aChromeURL,
PRBool& aClickedOK)
{
NS_ASSERTION(aPS, "Must have a print settings!");
aClickedOK = PR_FALSE;
nsresult rv = NS_ERROR_FAILURE;
// create a nsISupportsArray of the parameters
// being passed to the window
nsCOMPtr<nsISupportsArray> array;
NS_NewISupportsArray(getter_AddRefs(array));
if (!array) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintSettings> ps = aPS;
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
array->AppendElement(psSupports);
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
array->AppendElement(blkSupps);
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
NS_ASSERTION(array, "array must be a supports");
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
nsCOMPtr<nsIDOMWindow> newWindow;
rv = wwatch->OpenWindow(parent, aChromeURL,
"_blank", "chrome,modal,centerscreen", array,
getter_AddRefs(newWindow));
}
}
if (NS_SUCCEEDED(rv)) {
PRInt32 buttonPressed = 0;
ioParamBlock->GetInt(0, &buttonPressed);
if (buttonPressed == 1) {
aClickedOK = PR_TRUE;
} else {
rv = NS_ERROR_ABORT;
}
} else {
rv = NS_ERROR_ABORT;
}
return rv;
}
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecGTK
* @update dc 2/15/98
* @update syd 3/2/99
*
* gisburn: Please note that this function exists as 1:1 copy in other
* toolkits including:
* - GTK+-toolkit:
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* - Xlib-toolkit:
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
* - Qt-toolkit:
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
*
* ** Please update the other toolkits when changing this function.
*/
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings* aPS, PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
mPrintSettings = aPS;
// if there is a current selection then enable the "Selection" radio button
if (mPrintSettings) {
PRBool isOn;
mPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
}
}
char *path;
PRBool canPrint = PR_FALSE;
PRBool reversed = PR_FALSE;
PRBool color = PR_FALSE;
PRBool tofile = PR_FALSE;
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
PRInt32 paper_size = NS_LETTER_SIZE;
PRInt32 orientation = NS_PORTRAIT;
PRInt32 fromPage = 1;
PRInt32 toPage = 1;
PRUnichar *command = nsnull;
PRInt32 copies = 1;
PRUnichar *printer = nsnull;
PRUnichar *printfile = nsnull;
double dleft = 0.5;
double dright = 0.5;
double dtop = 0.5;
double dbottom = 0.5;
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
if (!aQuiet ) {
rv = DisplayXPDialog(mPrintSettings,
"chrome://global/content/printdialog.xul", canPrint);
}
else {
canPrint = PR_TRUE;
}
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
if (canPrint) {
if (aPS != nsnull) {
aPS->GetPrinterName(&printer);
aPS->GetPrintReversed(&reversed);
aPS->GetPrintInColor(&color);
aPS->GetPaperSize(&paper_size);
aPS->GetOrientation(&orientation);
aPS->GetPrintCommand(&command);
aPS->GetPrintRange(&printRange);
aPS->GetToFileName(&printfile);
aPS->GetPrintToFile(&tofile);
aPS->GetStartPageRange(&fromPage);
aPS->GetEndPageRange(&toPage);
aPS->GetNumCopies(&copies);
aPS->GetMarginTop(&dtop);
aPS->GetMarginLeft(&dleft);
aPS->GetMarginBottom(&dbottom);
aPS->GetMarginRight(&dright);
if (command != nsnull && printfile != nsnull) {
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
}
if (printer != nsnull)
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
#ifdef DEBUG_rods
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n",
dtop, dleft, dbottom, dright);
printf("printRange %d\n", printRange);
printf("fromPage %d\n", fromPage);
printf("toPage %d\n", toPage);
printf("tofile %d\n", tofile);
printf("printfile %s\n",
printfile? NS_ConvertUCS2toUTF8(printfile).get():"NULL");
printf("command %s\n",
command? NS_ConvertUCS2toUTF8(command).get():"NULL");
printf("printer %s\n",
printer? NS_ConvertUCS2toUTF8(printer).get():"NULL");
#endif /* DEBUG_rods */
} else {
#ifdef VMS
// Note to whoever puts the "lpr" into the prefs file. Please contact me
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
strcpy(mPrData.command, "print");
#else
strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}");
#endif /* VMS */
}
mPrData.top = dtop;
mPrData.bottom = dbottom;
mPrData.left = dleft;
mPrData.right = dright;
mPrData.fpf = !reversed;
mPrData.grayscale = !color;
mPrData.size = paper_size;
mPrData.orientation = orientation;
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
// PWD, HOME, or fail
if (!printfile) {
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
strcpy(mPrData.path, "mozilla.ps");
if ( path != (char *) nsnull )
sprintf(mPrData.path, "%s/mozilla.ps", path);
else
return NS_ERROR_FAILURE;
}
#ifdef NOT_IMPLEMENTED_YET
if (mGlobalNumPrinters) {
for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) {
if (!(mGlobalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1)))
mQueue = PrnDlg.SetPrinterQueue(i);
}
}
#endif /* NOT_IMPLEMENTED_YET */
if (command != nsnull) {
nsMemory::Free(command);
}
if (printfile != nsnull) {
nsMemory::Free(printfile);
}
return NS_OK;
}
return rv;
}
NS_IMETHODIMP nsDeviceContextSpecGTK::GetToPrinter(PRBool &aToPrinter)
{
aToPrinter = mPrData.toPrinter;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK::GetPrinterName ( char **aPrinter )
{
*aPrinter = &mPrData.printer[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK::GetCopies ( int &aCopies )
{
aCopies = mPrData.copies;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetFirstPageFirst ( PRBool &aFpf )
{
aFpf = mPrData.fpf;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetGrayscale ( PRBool &aGrayscale )
{
aGrayscale = mPrData.grayscale;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetSize ( int &aSize )
{
aSize = mPrData.size;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPageDimensions ( float &aWidth, float &aHeight )
{
if ( mPrData.size == NS_LETTER_SIZE ) {
aWidth = 8.5;
aHeight = 11.0;
} else if ( mPrData.size == NS_LEGAL_SIZE ) {
aWidth = 8.5;
aHeight = 14.0;
} else if ( mPrData.size == NS_EXECUTIVE_SIZE ) {
aWidth = 7.5;
aHeight = 10.0;
} else if ( mPrData.size == NS_A4_SIZE ) {
// 210mm X 297mm == 8.27in X 11.69in
aWidth = 8.27;
aHeight = 11.69;
} else if ( mPrData.size == NS_A3_SIZE ) {
// 297mm X 420mm == 11.69in X 16.53in
aWidth = 11.69;
aHeight = 16.53; }
if (mPrData.orientation == NS_LANDSCAPE) {
float temp;
temp = aWidth;
aWidth = aHeight;
aHeight = temp;
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetLandscape ( PRBool &landscape )
{
landscape = (mPrData.orientation == NS_LANDSCAPE);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetTopMargin ( float &value )
{
value = mPrData.top;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetBottomMargin ( float &value )
{
value = mPrData.bottom;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetRightMargin ( float &value )
{
value = mPrData.right;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetLeftMargin ( float &value )
{
value = mPrData.left;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetCommand ( char **aCommand )
{
*aCommand = &mPrData.command[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPath ( char **aPath )
{
*aPath = &mPrData.path[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetUserCancelled( PRBool &aCancel )
{
aCancel = mPrData.cancel;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK::GetPrintMethod(PrintMethod &aMethod)
{
/* printer names for the PostScript module alwas start with
* the NS_POSTSCRIPT_DRIVER_NAME string */
if (strncmp(mPrData.printer, NS_POSTSCRIPT_DRIVER_NAME,
NS_POSTSCRIPT_DRIVER_NAME_LEN) != 0)
aMethod = pmXprint;
else
aMethod = pmPostScript;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK::ClosePrintManager()
{
return NS_OK;
}
// Printer Enumerator
nsPrinterEnumeratorGTK::nsPrinterEnumeratorGTK()
{
NS_INIT_REFCNT();
}
NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorGTK, nsIPrinterEnumerator)
NS_IMETHODIMP nsPrinterEnumeratorGTK::EnumeratePrintersExtended(PRUint32* aCount, PRUnichar*** aResult)
{
NS_ENSURE_ARG(aCount);
NS_ENSURE_ARG_POINTER(aResult);
*aCount = 0;
*aResult = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsPrinterEnumeratorGTK::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
{
NS_ENSURE_ARG(aCount);
NS_ENSURE_ARG_POINTER(aResult);
if (aCount)
*aCount = 0;
else
return NS_ERROR_NULL_POINTER;
if (aResult)
*aResult = nsnull;
else
return NS_ERROR_NULL_POINTER;
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*));
if (!array && numPrinters > 0) {
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_OUT_OF_MEMORY;
}
int count = 0;
while( count < numPrinters )
{
PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count));
if (!str) {
for (int i = count - 1; i >= 0; i--)
nsMemory::Free(array[i]);
nsMemory::Free(array);
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_OUT_OF_MEMORY;
}
array[count++] = str;
}
*aCount = count;
*aResult = array;
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_OK;
}
NS_IMETHODIMP nsPrinterEnumeratorGTK::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings* aPrintSettings)
{
/* fixme: We simply ignore the |aPrinter| argument here
* We should get the supported printer attributes from the printer and
* populate the print job options dialog with these data instead of using
* the "default set" here.
* However, this requires changes on all platforms and is another big chunk
* of patches ... ;-(
*/
PRBool pressedOK;
return DisplayXPDialog(aPrintSettings,
"chrome://global/content/printjoboptions.xul",
pressedOK);
}
//----------------------------------------------------------------------
nsresult GlobalPrinters::InitializeGlobalPrinters ()
{
if (PrintersAreAllocated()) {
return NS_OK;
}
mGlobalNumPrinters = 0;
mGlobalPrinterList = new nsStringArray();
if (!mGlobalPrinterList)
return NS_ERROR_OUT_OF_MEMORY;
#ifdef USE_XPRINT
XPPrinterList plist = XpuGetPrinterList(nsnull, &mGlobalNumPrinters);
if (plist && (mGlobalNumPrinters > 0))
{
int i;
for( i = 0 ; i < mGlobalNumPrinters ; i++ )
{
mGlobalPrinterList->AppendString(nsString(NS_ConvertASCIItoUCS2(plist[i].name)));
}
XpuFreePrinterList(plist);
}
#endif /* USE_XPRINT */
/* add an entry for the default printer (see nsPostScriptObj.cpp) */
mGlobalPrinterList->AppendString(
nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME "default")));
mGlobalNumPrinters++;
/* get the list of printers */
char *printerList = nsnull;
/* the env var MOZILLA_PRINTER_LIST can "override" the prefs */
printerList = PR_GetEnv("MOZILLA_PRINTER_LIST");
if (!printerList) {
nsresult rv;
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
(void) pPrefs->CopyCharPref("print.printer_list", &printerList);
}
}
if (printerList) {
char *tok_lasts;
char *name;
/* PL_strtok_r() will modify the string - copy it! */
printerList = strdup(printerList);
if (!printerList)
return NS_ERROR_OUT_OF_MEMORY;
for( name = PL_strtok_r(printerList, " ", &tok_lasts) ;
name != nsnull ;
name = PL_strtok_r(nsnull, " ", &tok_lasts) )
{
mGlobalPrinterList->AppendString(
nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME)) +
nsString(NS_ConvertASCIItoUCS2(name)));
mGlobalNumPrinters++;
}
free(printerList);
}
if (mGlobalNumPrinters == 0)
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
return NS_OK;
}
//----------------------------------------------------------------------
void GlobalPrinters::FreeGlobalPrinters()
{
delete mGlobalPrinterList;
mGlobalPrinterList = nsnull;
mGlobalNumPrinters = 0;
}

View File

@@ -1,154 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecG_h___
#define nsDeviceContextSpecG_h___
#include "nsIDeviceContextSpec.h"
#include "nsIPrintOptions.h"
#include "nsVoidArray.h"
#include "nsIDeviceContextSpecPS.h"
#include "nsIPrintSettings.h"
#ifdef USE_XPRINT
#include "nsIDeviceContextSpecXPrint.h"
#endif /* USE_XPRINT */
#include "nsPrintdGTK.h"
typedef enum
{
pmInvalid = 0,
pmXprint,
pmPostScript
} PrintMethod;
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec ,
public nsIDeviceContextSpecPS
#ifdef USE_XPRINT
, public nsIDeviceContextSpecXp
#endif
{
public:
/**
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK();
NS_DECL_ISUPPORTS
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
/**
* Closes the printmanager if it is open.
* @update dc 2/13/98
* @update syd 3/20/99
* @return error status
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
NS_IMETHOD GetPrinterName ( char **aPrinter );
NS_IMETHOD GetCopies ( int &aCopies );
NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf );
NS_IMETHOD GetGrayscale( PRBool &aGrayscale );
NS_IMETHOD GetSize ( int &aSize );
NS_IMETHOD GetTopMargin ( float &value );
NS_IMETHOD GetBottomMargin ( float &value );
NS_IMETHOD GetLeftMargin ( float &value );
NS_IMETHOD GetRightMargin ( float &value );
NS_IMETHOD GetCommand ( char **aCommand );
NS_IMETHOD GetPath ( char **aPath );
NS_IMETHOD GetPageDimensions (float &aWidth, float &aHeight );
NS_IMETHOD GetLandscape (PRBool &aLandscape);
NS_IMETHOD GetUserCancelled( PRBool &aCancel );
NS_IMETHOD GetPrintMethod(PrintMethod &aMethod );
/**
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
* @update dc 2/16/98
*/
virtual ~nsDeviceContextSpecGTK();
protected:
nsCOMPtr<nsIPrintSettings> mPrintSettings;
UnixPrData mPrData;
};
//-------------------------------------------------------------------------
// Printer Enumerator
//-------------------------------------------------------------------------
class nsPrinterEnumeratorGTK : public nsIPrinterEnumerator
{
public:
nsPrinterEnumeratorGTK();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTERENUMERATOR
protected:
};
#endif /* !nsDeviceContextSpecG_h___ */

View File

@@ -1,313 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
#include "nsDrawingSurfaceGTK.h"
NS_IMPL_ISUPPORTS1(nsDrawingSurfaceGTK, nsIDrawingSurface)
//#define CHEAP_PERFORMANCE_MEASUREMENT
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
static PRTime mLockTime, mUnlockTime;
#endif
nsDrawingSurfaceGTK :: nsDrawingSurfaceGTK()
{
NS_INIT_REFCNT();
GdkVisual *v;
mPixmap = nsnull;
mGC = nsnull;
mDepth = 0;
mWidth = 0;
mHeight = 0;
mFlags = 0;
mImage = nsnull;
mLockWidth = 0;
mLockHeight = 0;
mLockFlags = 0;
mLockX = 0;
mLockY = 0;
mLocked = PR_FALSE;
v = ::gdk_rgb_get_visual();
mPixFormat.mRedMask = v->red_mask;
mPixFormat.mGreenMask = v->green_mask;
mPixFormat.mBlueMask = v->blue_mask;
// FIXME
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedCount = ConvertMaskToCount(v->red_mask);
mPixFormat.mGreenCount = ConvertMaskToCount(v->green_mask);
mPixFormat.mBlueCount = ConvertMaskToCount(v->blue_mask);;
mPixFormat.mRedShift = v->red_shift;
mPixFormat.mGreenShift = v->green_shift;
mPixFormat.mBlueShift = v->blue_shift;
// FIXME
mPixFormat.mAlphaShift = 0;
mDepth = v->depth;
}
nsDrawingSurfaceGTK :: ~nsDrawingSurfaceGTK()
{
if (mPixmap)
::gdk_pixmap_unref(mPixmap);
if (mImage)
::gdk_image_destroy(mImage);
if (mGC)
gdk_gc_unref(mGC);
}
/**
* Lock a rect of a drawing surface and return a
* pointer to the upper left hand corner of the
* bitmap.
* @param aX x position of subrect of bitmap
* @param aY y position of subrect of bitmap
* @param aWidth width of subrect of bitmap
* @param aHeight height of subrect of bitmap
* @param aBits out parameter for upper left hand
* corner of bitmap
* @param aStride out parameter for number of bytes
* to add to aBits to go from scanline to scanline
* @param aWidthBytes out parameter for number of
* bytes per line in aBits to process aWidth pixels
* @return error status
*
**/
NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
mLockTime = PR_Now();
// MOZ_TIMER_RESET(mLockTime);
// MOZ_TIMER_START(mLockTime);
#endif
#if 0
g_print("nsDrawingSurfaceGTK::Lock() called\n" \
" aX = %i, aY = %i,\n" \
" aWidth = %i, aHeight = %i,\n" \
" aBits, aStride, aWidthBytes,\n" \
" aFlags = %i\n", aX, aY, aWidth, aHeight, aFlags);
#endif
if (mLocked)
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
// Obtain an ximage from the pixmap.
mImage = ::gdk_image_get(mPixmap, mLockX, mLockY, mLockWidth, mLockHeight);
*aBits = GDK_IMAGE_XIMAGE(mImage)->data;
*aWidthBytes = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
*aStride = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
// MOZ_TIMER_STOP(mLockTime);
// MOZ_TIMER_LOG(("Time taken to lock: "));
// MOZ_TIMER_PRINT(mLockTime);
printf("Time taken to lock: %d\n", PR_Now() - mLockTime);
#endif
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Unlock(void)
{
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
mUnlockTime = PR_Now();
#endif
// g_print("nsDrawingSurfaceGTK::UnLock() called\n");
if (!mLocked)
{
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
return NS_ERROR_FAILURE;
}
// If the lock was not read only, put the bits back on the pixmap
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
{
#if 0
g_print("%p gdk_draw_image(pixmap=%p,lockx=%d,locky=%d,lockw=%d,lockh=%d)\n",
this,
mPixmap,
mLockX, mLockY,
mLockWidth, mLockHeight);
#endif
gdk_draw_image(mPixmap,
mGC,
mImage,
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight);
}
if (mImage)
::gdk_image_destroy(mImage);
mImage = nsnull;
mLocked = PR_FALSE;
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
printf("Time taken to unlock: %d\n", PR_Now() - mUnlockTime);
#endif
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mIsOffscreen;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsPixelAddressable(PRBool *aAddressable)
{
// FIXME
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
nsresult nsDrawingSurfaceGTK :: Init(GdkDrawable *aDrawable, GdkGC *aGC)
{
if (mGC)
gdk_gc_unref(mGC);
mGC = gdk_gc_ref(aGC);
mPixmap = aDrawable;
mWidth = ((GdkWindowPrivate*)aDrawable)->width;
mHeight = ((GdkWindowPrivate*)aDrawable)->height;
// XXX was i smoking crack when i wrote this comment?
// this is definatly going to be on the screen, as it will be the window of a
// widget or something.
mIsOffscreen = PR_FALSE;
if (mImage)
gdk_image_destroy(mImage);
mImage = nsnull;
g_return_val_if_fail(mPixmap != nsnull, NS_ERROR_FAILURE);
return NS_OK;
}
nsresult nsDrawingSurfaceGTK :: Init(GdkGC *aGC, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags)
{
// ::g_return_val_if_fail (aGC != nsnull, NS_ERROR_FAILURE);
// ::g_return_val_if_fail ((aWidth > 0) && (aHeight > 0), NS_ERROR_FAILURE);
if (mGC)
gdk_gc_unref(mGC);
mGC = gdk_gc_ref(aGC);
mWidth = aWidth;
mHeight = aHeight;
mFlags = aFlags;
// we can draw on this offscreen because it has no parent
mIsOffscreen = PR_TRUE;
mPixmap = ::gdk_pixmap_new(nsnull, mWidth, mHeight, mDepth);
if (mImage)
gdk_image_destroy(mImage);
mImage = nsnull;
return NS_OK;
}
/* inline */
PRUint8
nsDrawingSurfaceGTK::ConvertMaskToCount(unsigned long val)
{
PRUint8 retval = 0;
PRUint8 cur_bit = 0;
// walk through the number, incrementing the value if
// the bit in question is set.
while (cur_bit < (sizeof(unsigned long) * 8)) {
if ((val >> cur_bit) & 0x1) {
retval++;
}
cur_bit++;
}
return retval;
}

View File

@@ -1,132 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDrawingSurfaceGTK_h___
#define nsDrawingSurfaceGTK_h___
#include "nsIDrawingSurface.h"
#include "nsTimer.h"
#include <gtk/gtk.h>
class nsDrawingSurfaceGTK : public nsIDrawingSurface
{
public:
nsDrawingSurfaceGTK();
virtual ~nsDrawingSurfaceGTK();
/**
* Initialize a drawing surface using a windows DC.
* aDC is "owned" by the drawing surface until the drawing
* surface is destroyed.
* @param aDC HDC to initialize drawing surface with
* @return error status
**/
nsresult Init(GdkDrawable *aDrawable, GdkGC *aGC);
/**
* Initialize an offscreen drawing surface using a
* windows DC. aDC is not "owned" by this drawing surface, instead
* it is used to create a drawing surface compatible
* with aDC. if width or height are less than zero, aDC will
* be created with no offscreen bitmap installed.
* @param aDC HDC to initialize drawing surface with
* @param aWidth width of drawing surface
* @param aHeight height of drawing surface
* @param aFlags flags used to control type of drawing
* surface created
* @return error status
**/
nsresult Init(GdkGC *aGC, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags);
NS_DECL_ISUPPORTS
//nsIDrawingSurface interface
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
GdkDrawable *GetDrawable(void) { return mPixmap; }
void GetSize(PRUint32 *aWidth, PRUint32 *aHeight) { *aWidth = mWidth; *aHeight = mHeight; }
PRInt32 GetDepth() { return mDepth; }
protected:
inline PRUint8 ConvertMaskToCount(unsigned long val);
private:
/* general */
GdkPixmap *mPixmap;
GdkGC *mGC;
gint mDepth;
nsPixelFormat mPixFormat;
PRUint32 mWidth;
PRUint32 mHeight;
PRUint32 mFlags;
PRBool mIsOffscreen;
/* for locks */
GdkImage *mImage;
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
// MOZ_TIMER_DECLARE(mLockTime)
// MOZ_TIMER_DECLARE(mUnlockTime)
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,249 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFontMetricsGTK_h__
#define nsFontMetricsGTK_h__
#include "nsDeviceContextGTK.h"
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsRenderingContextGTK.h"
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#undef FONT_HAS_GLYPH
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
typedef gint (*nsFontCharSetConverter)(nsFontCharSetInfo* aSelf,
XFontStruct* aFont, const PRUnichar* aSrcBuf, PRInt32 aSrcLen,
char* aDestBuf, PRInt32 aDestLen);
struct nsFontCharSet;
struct nsFontFamily;
struct nsFontNode;
struct nsFontStretch;
class nsXFont;
class nsFontGTKUserDefined;
class nsFontMetricsGTK;
class nsFontGTK
{
public:
nsFontGTK();
nsFontGTK(nsFontGTK*);
virtual ~nsFontGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void LoadFont(void);
PRBool IsEmptyFont(XFontStruct*);
inline int SupportsChar(PRUnichar aChar)
{ return mFont && CCMAP_HAS_CHAR(mCCMap, aChar); };
virtual GdkFont* GetGDKFont(void);
virtual nsXFont* GetXFont(void);
virtual PRBool GetXFontIs10646(void);
virtual gint GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
virtual gint DrawString(nsRenderingContextGTK* aContext,
nsDrawingSurfaceGTK* aSurface, nscoord aX,
nscoord aY, const PRUnichar* aString,
PRUint32 aLength) = 0;
#ifdef MOZ_MATHML
// bounding metrics for a string
// remember returned values are not in app units
// - to emulate GetWidth () above
virtual nsresult
GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics) = 0;
#endif
PRUint16* mCCMap;
nsFontCharSetInfo* mCharSetInfo;
char* mName;
nsFontGTKUserDefined* mUserDefinedFont;
PRUint16 mSize;
PRUint16 mAABaseSize;
PRInt16 mBaselineAdjust;
// these values are not in app units, they need to be scaled with
// nsIDeviceContext::GetDevUnitsToAppUnits()
PRInt16 mMaxAscent;
PRInt16 mMaxDescent;
protected:
GdkFont* mFont;
GdkFont* mFontHolder;
nsXFont* mXFont;
PRBool mAlreadyCalledLoadFont;
};
class nsFontMetricsGTK : public nsIFontMetrics
{
public:
nsFontMetricsGTK();
virtual ~nsFontMetricsGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
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);
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
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 GetFont(const nsFont *&aFont);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
nsFontGTK* FindFont(PRUnichar aChar);
nsFontGTK* FindUserDefinedFont(PRUnichar aChar);
nsFontGTK* FindStyleSheetSpecificFont(PRUnichar aChar);
nsFontGTK* FindStyleSheetGenericFont(PRUnichar aChar);
nsFontGTK* FindLangGroupPrefFont(nsIAtom* aLangGroup, PRUnichar aChar);
nsFontGTK* FindLangGroupFont(nsIAtom* aLangGroup, PRUnichar aChar, nsCString* aName);
nsFontGTK* FindAnyFont(PRUnichar aChar);
nsFontGTK* FindSubstituteFont(PRUnichar aChar);
nsFontGTK* SearchNode(nsFontNode* aNode, PRUnichar aChar);
nsFontGTK* TryAliases(nsCString* aName, PRUnichar aChar);
nsFontGTK* TryFamily(nsCString* aName, PRUnichar aChar);
nsFontGTK* TryNode(nsCString* aName, PRUnichar aChar);
nsFontGTK* TryNodes(nsAWritableCString &aFFREName, PRUnichar aChar);
nsFontGTK* TryLangGroup(nsIAtom* aLangGroup, nsCString* aName, PRUnichar aChar);
nsFontGTK* AddToLoadedFontsList(nsFontGTK* aFont);
nsFontGTK* FindNearestSize(nsFontStretch* aStretch, PRUint16 aSize);
nsFontGTK* GetAASBBaseFont(nsFontStretch* aStretch,
nsFontCharSetInfo* aCharSet);
nsFontGTK* PickASizeAndLoad(nsFontStretch* aStretch,
nsFontCharSetInfo* aCharSet,
PRUnichar aChar,
const char *aName);
static nsresult FamilyExists(const nsString& aFontName);
//friend struct nsFontGTK;
nsFontGTK **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsFontGTK *mSubstituteFont;
nsCStringArray mFonts;
PRUint16 mFontsIndex;
nsAutoVoidArray mFontIsGeneric;
nsCAutoString mDefaultFont;
nsCString *mGeneric;
nsCOMPtr<nsIAtom> mLangGroup;
nsCAutoString mUserDefined;
PRUint8 mTriedAllGenerics;
PRUint8 mIsUserDefined;
protected:
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
nsFontGTK *mWesternFont;
nscoord mLeading;
nscoord mEmHeight;
nscoord mEmAscent;
nscoord mEmDescent;
nscoord mMaxHeight;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
nscoord mSpaceWidth;
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
nsFontCharSetConverter mDocConverterType;
};
class nsFontEnumeratorGTK : public nsIFontEnumerator
{
public:
nsFontEnumeratorGTK();
NS_DECL_ISUPPORTS
NS_DECL_NSIFONTENUMERATOR
};
#endif

View File

@@ -1,320 +0,0 @@
/* -*- 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" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Mike Shaver <shaver@zeroknowledge.com>
* Tomi Leppikangas <Tomi.Leppikangas@oulu.fi>
*/
#include <stdio.h>
#include "nsGCCache.h"
#include "nsISupportsUtils.h"
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
#include <X11/Xlib.h>
/* The GC cache is shared among all windows, since it doesn't hog
any scarce resources (like colormap entries.) */
GdkRegion *nsGCCache::copyRegion = NULL;
MOZ_DECL_CTOR_COUNTER(nsGCCache)
nsGCCache::nsGCCache()
{
MOZ_COUNT_CTOR(nsGCCache);
PR_INIT_CLIST(&GCCache);
PR_INIT_CLIST(&GCFreeList);
for (int i = 0; i < GC_CACHE_SIZE; i++) {
GCCacheEntry *entry = new GCCacheEntry();
entry->gc=NULL;
PR_INSERT_LINK(&entry->clist, &GCFreeList);
}
DEBUG_METER(memset(&GCCacheStats, 0, sizeof(GCCacheStats));)
}
/* static */ void
nsGCCache::Shutdown()
{
if (copyRegion) {
gdk_region_destroy(copyRegion);
copyRegion = nsnull;
}
}
void
nsGCCache::move_cache_entry(PRCList *clist)
{
/* thread on the freelist, at the front */
PR_REMOVE_LINK(clist);
PR_INSERT_LINK(clist, &GCFreeList);
}
void
nsGCCache::free_cache_entry(PRCList *clist)
{
GCCacheEntry *entry = (GCCacheEntry *)clist;
gdk_gc_unref(entry->gc);
if (entry->clipRegion)
gdk_region_destroy(entry->clipRegion);
/* thread on the freelist, at the front */
PR_REMOVE_LINK(clist);
memset(entry, 0, sizeof(*entry));
PR_INSERT_LINK(clist, &GCFreeList);
}
nsGCCache::~nsGCCache()
{
PRCList *head;
MOZ_COUNT_DTOR(nsGCCache);
ReportStats();
while (!PR_CLIST_IS_EMPTY(&GCCache)) {
head = PR_LIST_HEAD(&GCCache);
if (head == &GCCache)
break;
free_cache_entry(head);
}
while (!PR_CLIST_IS_EMPTY(&GCFreeList)) {
head = PR_LIST_HEAD(&GCFreeList);
if (head == &GCFreeList)
break;
PR_REMOVE_LINK(head);
delete (GCCacheEntry *)head;
}
}
void
nsGCCache::ReportStats() {
DEBUG_METER(
fprintf(stderr, "GC Cache:\n\thits:");
int hits = 0;
for (int i = 0; i < GC_CACHE_SIZE; i++) {
fprintf(stderr, " %4d", GCCacheStats.hits[i]);
hits+=GCCacheStats.hits[i];
}
int total = hits + GCCacheStats.misses;
float percent = float(float(hits) / float(total));
percent *= 100;
fprintf(stderr, "\n\thits: %d, misses: %d, hit percent: %f%%\n",
hits, GCCacheStats.misses, percent);
);
}
GdkRegion *
nsGCCache::gdk_region_copy(GdkRegion *region)
{
if (!copyRegion) copyRegion = gdk_region_new();
return gdk_regions_union(region, copyRegion);
}
/* Dispose of entries matching the given flags, compressing the GC cache */
void nsGCCache::Flush(unsigned long flags)
{
while (!PR_CLIST_IS_EMPTY(&GCCache)) {
PRCList *head = PR_LIST_HEAD(&GCCache);
if (head == &GCCache)
break;
GCCacheEntry *entry = (GCCacheEntry *)head;
if (entry->flags & flags)
free_cache_entry(head);
}
}
GdkGC *nsGCCache::GetGC(GdkWindow *window, GdkGCValues *gcv, GdkGCValuesMask flags, GdkRegion *clipRegion)
{
PRCList *iter;
GCCacheEntry *entry;
DEBUG_METER(int i = 0;)
for (iter = PR_LIST_HEAD(&GCCache); iter != &GCCache;
iter = PR_NEXT_LINK(iter)) {
entry = (GCCacheEntry *)iter;
if (flags == entry->flags &&
!memcmp (gcv, &entry->gcv, sizeof (*gcv))) {
/* if there's a clipRegion, we have to match */
if ((clipRegion && entry->clipRegion &&
gdk_region_equal(clipRegion, entry->clipRegion)) ||
/* and if there isn't, we can't have one */
(!clipRegion && !entry->clipRegion)) {
/* move to the front of the list, if needed */
if (iter != PR_LIST_HEAD(&GCCache)) {
PR_REMOVE_LINK(iter);
PR_INSERT_LINK(iter, &GCCache);
}
DEBUG_METER(GCCacheStats.hits[i]++;)
return gdk_gc_ref(entry->gc);
}
}
DEBUG_METER(++i;)
}
/* might need to forcibly free the LRU cache entry */
if (PR_CLIST_IS_EMPTY(&GCFreeList)) {
DEBUG_METER(GCCacheStats.reclaim++);
move_cache_entry(PR_LIST_TAIL(&GCCache));
}
DEBUG_METER(GCCacheStats.misses++;)
iter = PR_LIST_HEAD(&GCFreeList);
PR_REMOVE_LINK(iter);
PR_INSERT_LINK(iter, &GCCache);
entry = (GCCacheEntry *)iter;
if (!entry->gc) {
// No old GC, greate new
entry->gc = gdk_gc_new_with_values(window, gcv, flags);
entry->flags = flags;
entry->gcv = *gcv;
entry->clipRegion = NULL;
//printf("creating new gc=%X\n",entry->gc);
}
else if ( ((GdkGCPrivate*)entry->gc)->ref_count > 1 ) {
// Old GC still in use, create new
gdk_gc_unref(entry->gc);
entry->gc=gdk_gc_new_with_values(window, gcv, flags);
entry->flags = flags;
entry->gcv = *gcv;
entry->clipRegion = NULL;
//printf("creating new (use)gc=%X\n",entry->gc);
}
else {
ReuseGC(entry, gcv, flags);
}
if (clipRegion) {
entry->clipRegion = gdk_region_copy(clipRegion);
if (entry->clipRegion)
gdk_gc_set_clip_region(entry->gc, entry->clipRegion);
/* XXX what if it fails? */
}
return gdk_gc_ref(entry->gc);
}
void nsGCCache::ReuseGC(GCCacheEntry *entry, GdkGCValues *gcv, GdkGCValuesMask flags)
{
// We have old GC, reuse it and check what
// we have to change
XGCValues xvalues;
unsigned long xvalues_mask=0;
if (entry->clipRegion) {
// set it to none here and then set the clip region with
// gdk_gc_set_clip_region in GetGC()
xvalues.clip_mask = None;
xvalues_mask |= GCClipMask;
gdk_region_destroy(entry->clipRegion);
entry->clipRegion = NULL;
}
if (entry->gcv.foreground.pixel != gcv->foreground.pixel) {
xvalues.foreground = gcv->foreground.pixel;
xvalues_mask |= GCForeground;
}
if (entry->gcv.function != gcv->function) {
switch (gcv->function) {
case GDK_COPY:
xvalues.function = GXcopy;
break;
case GDK_INVERT:
xvalues.function = GXinvert;
break;
case GDK_XOR:
xvalues.function = GXxor;
break;
case GDK_CLEAR:
xvalues.function = GXclear;
break;
case GDK_AND:
xvalues.function = GXand;
break;
case GDK_AND_REVERSE:
xvalues.function = GXandReverse;
break;
case GDK_AND_INVERT:
xvalues.function = GXandInverted;
break;
case GDK_NOOP:
xvalues.function = GXnoop;
break;
case GDK_OR:
xvalues.function = GXor;
break;
case GDK_EQUIV:
xvalues.function = GXequiv;
break;
case GDK_OR_REVERSE:
xvalues.function = GXorReverse;
break;
case GDK_COPY_INVERT:
xvalues.function = GXcopyInverted;
break;
case GDK_OR_INVERT:
xvalues.function = GXorInverted;
break;
case GDK_NAND:
xvalues.function = GXnand;
break;
case GDK_SET:
xvalues.function = GXset;
break;
}
xvalues_mask |= GCFunction;
}
if(entry->gcv.font != gcv->font && flags & GDK_GC_FONT) {
xvalues.font = ((XFontStruct *)GDK_FONT_XFONT(gcv->font))->fid;
xvalues_mask |= GCFont;
}
if (entry->gcv.line_style != gcv->line_style) {
switch (gcv->line_style) {
case GDK_LINE_SOLID:
xvalues.line_style = LineSolid;
break;
case GDK_LINE_ON_OFF_DASH:
xvalues.line_style = LineOnOffDash;
break;
case GDK_LINE_DOUBLE_DASH:
xvalues.line_style = LineDoubleDash;
break;
}
xvalues_mask |= GCLineStyle;
}
if (xvalues_mask != 0) {
XChangeGC(GDK_GC_XDISPLAY(entry->gc), GDK_GC_XGC(entry->gc),
xvalues_mask, &xvalues);
}
entry->flags = flags;
entry->gcv = *gcv;
}

View File

@@ -1,82 +0,0 @@
/* -*- 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" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Mike Shaver <shaver@zeroknowledge.com>
*/
#include <gdk/gdk.h>
#include <string.h>
#include "prclist.h"
#ifndef nsGCCache_h___
#define nsGCCache_h___
#define countof(x) ((int)(sizeof(x) / sizeof (*x)))
#define GC_CACHE_SIZE 10
#ifdef DEBUG
#define DEBUG_METER(x) x
#else
#define DEBUG_METER(x)
#endif
struct GCCacheEntry
{
PRCList clist;
GdkGCValuesMask flags;
GdkGCValues gcv;
GdkRegion *clipRegion;
GdkGC *gc;
};
class nsGCCache
{
public:
nsGCCache();
virtual ~nsGCCache();
static void Shutdown();
void Flush(unsigned long flags);
GdkGC *GetGC(GdkWindow *window, GdkGCValues *gcv, GdkGCValuesMask flags, GdkRegion *clipRegion);
private:
void ReuseGC(GCCacheEntry *entry, GdkGCValues *gcv, GdkGCValuesMask flags);
PRCList GCCache;
PRCList GCFreeList;
void free_cache_entry(PRCList *clist);
void move_cache_entry(PRCList *clist);
static GdkRegion * gdk_region_copy(GdkRegion *region);
static GdkRegion *copyRegion;
void ReportStats();
DEBUG_METER(
struct {
int hits[GC_CACHE_SIZE];
int misses;
int reclaim;
} GCCacheStats;
)
};
#endif

View File

@@ -1,217 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* 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>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
*
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsBlender.h"
#include "nsFontMetricsGTK.h"
#include "nsRenderingContextGTK.h"
#include "nsDeviceContextGTK.h"
// aka nsDeviceContextSpecGTK.h
#include "nsDeviceContextSpecG.h"
// aka nsDeviceContextSpecFactoryGTK.h
#include "nsDeviceContextSpecFactoryG.h"
#include "nsScreenManagerGtk.h"
#include "nsScriptableRegion.h"
#include "nsDeviceContextGTK.h"
#include "nsImageGTK.h"
#include "nsPrintOptionsGTK.h"
#include "nsFontList.h"
#include "nsRegionGTK.h"
#include "nsGCCache.h"
#ifdef NATIVE_THEME_SUPPORT
#include "nsNativeThemeGTK.h"
#endif
// objects that just require generic constructors
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGtk)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsGTK)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorGTK)
#ifdef NATIVE_THEME_SUPPORT
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeGTK)
#endif
// our custom constructors
static NS_IMETHODIMP nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsresult rv;
nsIScriptableRegion *inst;
if ( !aResult )
{
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = nsnull;
if (aOuter)
{
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
// create an nsRegionGtk and get the scriptable region from it
nsCOMPtr <nsIRegion> rgn;
NS_NEWXPCOM(rgn, nsRegionGTK);
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 nsModuleComponentInfo components[] =
{
{ "Gtk Font Metrics",
NS_FONT_METRICS_CID,
// "@mozilla.org/gfx/font_metrics/gtk;1",
"@mozilla.org/gfx/fontmetrics;1",
nsFontMetricsGTKConstructor },
{ "Gtk Device Context",
NS_DEVICE_CONTEXT_CID,
// "@mozilla.org/gfx/device_context/gtk;1",
"@mozilla.org/gfx/devicecontext;1",
nsDeviceContextGTKConstructor },
{ "Gtk Rendering Context",
NS_RENDERING_CONTEXT_CID,
// "@mozilla.org/gfx/rendering_context/gtk;1",
"@mozilla.org/gfx/renderingcontext;1",
nsRenderingContextGTKConstructor },
{ "Gtk Image",
NS_IMAGE_CID,
// "@mozilla.org/gfx/image/gtk;1",
"@mozilla.org/gfx/image;1",
nsImageGTKConstructor },
{ "Gtk Region",
NS_REGION_CID,
"@mozilla.org/gfx/region/gtk;1",
nsRegionGTKConstructor },
{ "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 },
{ "Gtk Device Context Spec",
NS_DEVICE_CONTEXT_SPEC_CID,
// "@mozilla.org/gfx/device_context_spec/gtk;1",
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecGTKConstructor },
{ "Gtk Device Context Spec Factory",
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
// "@mozilla.org/gfx/device_context_spec_factory/gtk;1",
"@mozilla.org/gfx/devicecontextspecfactory;1",
nsDeviceContextSpecFactoryGTKConstructor },
{ "Print Options",
NS_PRINTOPTIONS_CID,
// "@mozilla.org/gfx/printoptions;1",
"@mozilla.org/gfx/printoptions;1",
nsPrintOptionsGTKConstructor },
{ "GTK Font Enumerator",
NS_FONT_ENUMERATOR_CID,
// "@mozilla.org/gfx/font_enumerator/gtk;1",
"@mozilla.org/gfx/fontenumerator;1",
nsFontEnumeratorGTKConstructor },
{ "Font List",
NS_FONTLIST_CID,
// "@mozilla.org/gfx/fontlist;1"
NS_FONTLIST_CONTRACTID,
nsFontListConstructor },
{ "Gtk Screen Manager",
NS_SCREENMANAGER_CID,
// "@mozilla.org/gfx/screenmanager/gtk;1",
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerGtkConstructor },
{ "Gtk Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
// "@mozilla.org/gfx/printer_enumerator/gtk;1",
"@mozilla.org/gfx/printerenumerator;1",
nsPrinterEnumeratorGTKConstructor }
#ifdef NATIVE_THEME_SUPPORT
,{ "Native Theme Renderer",
NS_THEMERENDERER_CID,
"@mozilla.org/chrome/chrome-native-theme;1",
nsNativeThemeGTKConstructor }
#endif
};
PR_STATIC_CALLBACK(void)
nsGfxGTKModuleDtor(nsIModule *self)
{
nsRenderingContextGTK::Shutdown();
nsDeviceContextGTK::Shutdown();
nsGCCache::Shutdown();
nsRegionGTK::Shutdown();
}
NS_IMPL_NSGETMODULE_WITH_DTOR(nsGfxGTKModule, components, nsGfxGTKModuleDtor)

View File

@@ -1,141 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsGraphicsStateGTK.h"
//////////////////////////////////////////////////////////////////////////
nsGraphicsState::nsGraphicsState()
{
mMatrix = nsnull;
mClipRegion = nsnull;
mColor = 0;
mLineStyle = nsLineStyle_kSolid;
mFontMetrics = nsnull;
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsState::~nsGraphicsState()
{
NS_IF_RELEASE(mFontMetrics);
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool::nsGraphicsStatePool()
{
mFreeList = nsnull;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Public nsGraphicsStatePool
//
//////////////////////////////////////////////////////////////////////////
/* static */ nsGraphicsState *
nsGraphicsStatePool::GetNewGS()
{
nsGraphicsStatePool * thePool = PrivateGetPool();
return thePool->PrivateGetNewGS();
}
//////////////////////////////////////////////////////////////////////////
/* static */ void
nsGraphicsStatePool::ReleaseGS(nsGraphicsState* aGS)
{
nsGraphicsStatePool * thePool = PrivateGetPool();
thePool->PrivateReleaseGS(aGS);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Private nsGraphicsStatePool
//
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool *
nsGraphicsStatePool::gsThePool = nsnull;
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool *
nsGraphicsStatePool::PrivateGetPool()
{
if (nsnull == gsThePool)
{
gsThePool = new nsGraphicsStatePool();
}
return gsThePool;
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsStatePool::~nsGraphicsStatePool()
{
nsGraphicsState* gs = mFreeList;
while (gs != nsnull) {
nsGraphicsState* next = gs->mNext;
delete gs;
gs = next;
}
}
//////////////////////////////////////////////////////////////////////////
nsGraphicsState *
nsGraphicsStatePool::PrivateGetNewGS()
{
nsGraphicsState* gs = mFreeList;
if (gs != nsnull) {
mFreeList = gs->mNext;
return gs;
}
return new nsGraphicsState;
}
//////////////////////////////////////////////////////////////////////////
void
nsGraphicsStatePool::PrivateReleaseGS(nsGraphicsState* aGS)
{
// aGS->Clear();
aGS->mNext = mFreeList;
mFreeList = aGS;
}
//////////////////////////////////////////////////////////////////////////

View File

@@ -1,91 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsGraphicsStateGTK_h___
#define nsGraphicsStateGTK_h___
#include "nsIRenderingContext.h"
#include "nsIFontMetrics.h"
#include "nsTransform2D.h"
#include "nsRegionGTK.h"
#include "nsCOMPtr.h"
class nsGraphicsState
{
public:
nsTransform2D *mMatrix;
nsCOMPtr<nsIRegion> mClipRegion;
nscolor mColor;
nsLineStyle mLineStyle;
nsIFontMetrics *mFontMetrics;
nsGraphicsState *mNext; // link into free list of graphics states.
friend class nsGraphicsStatePool;
#ifndef USE_GS_POOL
friend class nsRenderingContextGTK;
#endif
private:
nsGraphicsState();
~nsGraphicsState();
};
class nsGraphicsStatePool
{
public:
static nsGraphicsState * GetNewGS();
static void ReleaseGS(nsGraphicsState* aGS);
nsGraphicsStatePool();
~nsGraphicsStatePool();
private:
nsGraphicsState* mFreeList;
static nsGraphicsStatePool * PrivateGetPool();
nsGraphicsState * PrivateGetNewGS();
void PrivateReleaseGS(nsGraphicsState* aGS);
static nsGraphicsStatePool * gsThePool;
};
#endif /* nsGraphicsStateGTK_h___ */

Some files were not shown because too many files have changed in this diff Show More