Compare commits
6 Commits
Bugzilla_P
...
IMGLIB2_20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc10a03222 | ||
|
|
f81da28e3f | ||
|
|
529a2de1e6 | ||
|
|
c2aa591129 | ||
|
|
7695f8fdf6 | ||
|
|
10359a9d9b |
175
mozilla/Makefile.in
Normal file
175
mozilla/Makefile.in
Normal file
@@ -0,0 +1,175 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
include $(topsrcdir)/build/unix/modules.mk
|
||||
|
||||
ifneq ($(BUILD_MODULES),all)
|
||||
|
||||
DIRS = $(BUILD_MODULE_DIRS)
|
||||
EXPORT_DIRS = $(BUILD_MODULE_DEP_DIRS)
|
||||
|
||||
else
|
||||
|
||||
DIRS = config build
|
||||
|
||||
ifdef MOZ_L10N
|
||||
DIRS += l10n
|
||||
endif
|
||||
|
||||
ifdef MOZ_JAVA_SUPPLEMENT
|
||||
DIRS += \
|
||||
java/util \
|
||||
java/webclient \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
# boehm needs to be built before XPCOM
|
||||
ifdef GC_LEAK_DETECTOR
|
||||
DIRS += gc/boehm
|
||||
endif
|
||||
|
||||
DIRS += $(NSPRPUB_DIR)
|
||||
|
||||
DIRS += dbm modules/libreg js string xpcom js/src/xpconnect
|
||||
|
||||
ifdef MOZ_OJI
|
||||
DIRS += js/src/liveconnect
|
||||
endif
|
||||
|
||||
ifndef MOZ_NATIVE_ZLIB
|
||||
DIRS += modules/zlib
|
||||
endif
|
||||
|
||||
ifndef MOZ_NATIVE_JPEG
|
||||
DIRS += jpeg
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
DIRS += gfx/src/xlibrgb widget/src/xlibxtbin
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
DIRS += widget/src/gtksuperwin widget/src/gtkxtbin
|
||||
endif
|
||||
|
||||
# Linux and Solaris installer needs standalone libjar, hence standalone zlib
|
||||
ifneq (,$(filter Linux SunOS,$(OS_ARCH)))
|
||||
DIRS += modules/zlib/standalone
|
||||
endif
|
||||
|
||||
DIRS += \
|
||||
widget/timer \
|
||||
include \
|
||||
modules/libutil \
|
||||
netwerk \
|
||||
modules/mpfilelocprovider \
|
||||
uriloader \
|
||||
intl \
|
||||
modules/libpref \
|
||||
modules/libimg \
|
||||
modules/oji \
|
||||
modules/libjar \
|
||||
caps \
|
||||
rdf \
|
||||
expat \
|
||||
htmlparser \
|
||||
gfx \
|
||||
gfx2 \
|
||||
modules/libpr0n \
|
||||
modules/plugin \
|
||||
dom \
|
||||
view \
|
||||
widget \
|
||||
content \
|
||||
layout \
|
||||
db \
|
||||
docshell \
|
||||
webshell \
|
||||
embedding \
|
||||
editor \
|
||||
sun-java \
|
||||
profile \
|
||||
themes \
|
||||
$(NULL)
|
||||
|
||||
# This must preceed xpfe
|
||||
ifdef MOZ_JPROF
|
||||
DIRS += tools/jprof
|
||||
endif
|
||||
|
||||
ifdef MOZ_BUILD_XPFE
|
||||
DIRS += xpfe
|
||||
endif
|
||||
|
||||
DIRS += xpinstall
|
||||
|
||||
ifdef MOZ_EXTENSIONS
|
||||
DIRS += extensions
|
||||
endif
|
||||
|
||||
ifdef MOZ_MAIL_NEWS
|
||||
DIRS += mailnews
|
||||
endif
|
||||
|
||||
ifdef MOZ_LEAKY
|
||||
DIRS += tools/leaky
|
||||
endif
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += xpcom/tests
|
||||
endif
|
||||
|
||||
ifdef MOZ_LDAP_XPCOM
|
||||
DIRS += directory/c-sdk/ldap directory/xpcom
|
||||
endif
|
||||
|
||||
DIRS += l10n
|
||||
|
||||
ifdef MOZ_STATIC_COMPONENTS
|
||||
DIRS += modules/staticmod
|
||||
endif
|
||||
|
||||
endif # BUILD_MODULES == all
|
||||
|
||||
STATIC_MAKEFILES := $(NSPRPUB_DIR)
|
||||
|
||||
GARBAGE_DIRS += dist
|
||||
DIST_GARBAGE = config.cache config.log config.status config-defs.h \
|
||||
dependencies.beos config/autoconf.mk config/myrules.mk config/myconfig.mk \
|
||||
unallmakefiles \
|
||||
$(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export::
|
||||
+$(LOOP_OVER_EXPORT_DIRS)
|
||||
|
||||
distclean::
|
||||
cat unallmakefiles | $(XARGS) rm -f
|
||||
rm -f unallmakefiles $(DIST_GARBAGE)
|
||||
|
||||
1093
mozilla/allmakefiles.sh
Executable file
1093
mozilla/allmakefiles.sh
Executable file
File diff suppressed because it is too large
Load Diff
90
mozilla/content/html/content/public/nsIHTMLContent.h
Normal file
90
mozilla/content/html/content/public/nsIHTMLContent.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
#ifndef nsIHTMLContent_h___
|
||||
#define nsIHTMLContent_h___
|
||||
|
||||
#include "nsIXMLContent.h"
|
||||
#include "nsHTMLValue.h"
|
||||
class nsString;
|
||||
class nsIFrame;
|
||||
class nsIStyleRule;
|
||||
class nsIMutableStyleContext;
|
||||
class nsIPresContext;
|
||||
class nsIHTMLMappedAttributes;
|
||||
class nsIURI;
|
||||
|
||||
// IID for the nsIHTMLContent class
|
||||
#define NS_IHTMLCONTENT_IID \
|
||||
{ 0xb9e110b0, 0x94d6, 0x11d1, \
|
||||
{0x89, 0x5c, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
|
||||
|
||||
typedef void (*nsMapAttributesFunc)(const nsIHTMLMappedAttributes* aAttributes,
|
||||
nsIMutableStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
// Abstract interface for all html content
|
||||
class nsIHTMLContent : public nsIXMLContent
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLCONTENT_IID)
|
||||
|
||||
/**
|
||||
* If this html content is a container, then compact asks it to minimize
|
||||
* it's storage usage.
|
||||
*/
|
||||
NS_IMETHOD Compact() = 0;
|
||||
|
||||
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const = 0;
|
||||
NS_IMETHOD GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
||||
nsMapAttributesFunc& aMapFunc) const = 0;
|
||||
|
||||
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsAWritableString& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAReadableString& aValue,
|
||||
nsHTMLValue& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Get the base URL for any relative URLs within this piece
|
||||
* of content. Generally, this is the document's base URL,
|
||||
* but certain content carries a local base for backward
|
||||
* compatibility.
|
||||
*/
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aBaseURL) const = 0;
|
||||
|
||||
/**
|
||||
* Get the base target for any links within this piece
|
||||
* of content. Generally, this is the document's base target,
|
||||
* but certain content carries a local base for backward
|
||||
* compatibility.
|
||||
*/
|
||||
NS_IMETHOD GetBaseTarget(nsAWritableString& aBaseTarget) const = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIHTMLContent_h___ */
|
||||
492
mozilla/content/html/document/src/nsImageDocument.cpp
Normal file
492
mozilla/content/html/document/src/nsImageDocument.cpp
Normal file
@@ -0,0 +1,492 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#define USE_IMG2 1
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLDocument.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#ifdef USE_IMG2
|
||||
#include "imgIRequest.h"
|
||||
#include "imgILoader.h"
|
||||
#else
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsIImageRequest.h"
|
||||
#endif
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
// Needed for Localization
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
#define NSIMAGEDOCUMENT_PROPERTIES_URI "chrome://communicator/locale/layout/ImageDocument.properties"
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
|
||||
// done L10N
|
||||
|
||||
// XXX TODO:
|
||||
|
||||
// 1. hookup the original stream to the image library directly so that we
|
||||
// don't have to load the image twice.
|
||||
|
||||
// 2. have a synthetic document url that we load that has patterns in it
|
||||
// that we replace with the image url (so that we can customize the
|
||||
// the presentation of the image): we could add script code to set the
|
||||
// width/height to provide scale buttons, we could show the image
|
||||
// attributes; etc.; should we have a seperate style sheet?
|
||||
|
||||
// 3. override the save-as methods so that we don't write out our synthetic
|
||||
// html
|
||||
|
||||
|
||||
class nsImageDocument : public nsHTMLDocument {
|
||||
public:
|
||||
nsImageDocument();
|
||||
virtual ~nsImageDocument();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE);
|
||||
|
||||
nsresult CreateSyntheticDocument();
|
||||
|
||||
#ifndef USE_IMG2
|
||||
nsresult StartImageLoad(nsIURI* aURL, nsIStreamListener*& aListener);
|
||||
#endif
|
||||
nsresult EndLayout(nsISupports *ctxt,
|
||||
nsresult status,
|
||||
const PRUnichar *errorMsg);
|
||||
nsresult UpdateTitle( void );
|
||||
|
||||
void StartLayout();
|
||||
#ifdef USE_IMG2
|
||||
nsCOMPtr<imgIRequest> mImageRequest;
|
||||
#else
|
||||
nsIImageRequest* mImageRequest;
|
||||
#endif
|
||||
nscolor mBlack;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class ImageListener : public nsIStreamListener {
|
||||
public:
|
||||
ImageListener(nsImageDocument* aDoc);
|
||||
virtual ~ImageListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
// nsIStreamObserver methods:
|
||||
NS_DECL_NSISTREAMOBSERVER
|
||||
|
||||
// nsIStreamListener methods:
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
nsImageDocument* mDocument;
|
||||
#ifdef USE_IMG2
|
||||
nsCOMPtr<nsIStreamListener> mNextStream;
|
||||
#else
|
||||
nsIStreamListener *mNextStream;
|
||||
#endif
|
||||
};
|
||||
|
||||
ImageListener::ImageListener(nsImageDocument* aDoc)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mDocument = aDoc;
|
||||
NS_ADDREF(aDoc);
|
||||
}
|
||||
|
||||
ImageListener::~ImageListener()
|
||||
{
|
||||
NS_RELEASE(mDocument);
|
||||
#ifndef USE_IMG2
|
||||
NS_IF_RELEASE(mNextStream);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(ImageListener, nsIStreamListener)
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIURI* uri;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
if (!channel) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = channel->GetURI(&uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef USE_IMG2
|
||||
nsCOMPtr<nsIStreamListener> kungFuDeathGrip(this);
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1"));
|
||||
il->LoadImageWithChannel(channel, nsnull, nsnull, getter_AddRefs(mNextStream),
|
||||
getter_AddRefs(mDocument->mImageRequest));
|
||||
|
||||
// XXX
|
||||
// if we get a cache hit, and we cancel the channel in the above function,
|
||||
// do we call OnStopRequest before we call StartLayout?
|
||||
// if so, should LoadImageWithChannel() not call channel->Cancel() ?
|
||||
|
||||
mDocument->StartLayout();
|
||||
|
||||
#else
|
||||
mDocument->StartImageLoad(uri, mNextStream);
|
||||
#endif
|
||||
NS_RELEASE(uri);
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return mNextStream->OnStartRequest(request, ctxt);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageListener::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg)
|
||||
{
|
||||
if(mDocument){
|
||||
mDocument->EndLayout(ctxt, status, errorMsg);
|
||||
}
|
||||
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return mNextStream->OnStopRequest(request, ctxt, status, errorMsg);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageListener::OnDataAvailable(nsIRequest* request, nsISupports *ctxt,
|
||||
nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
||||
{
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return mNextStream->OnDataAvailable(request, ctxt, inStr, sourceOffset, count);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewImageDocument(nsIDocument** aInstancePtrResult)
|
||||
{
|
||||
nsImageDocument* doc = new nsImageDocument();
|
||||
if(doc)
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDocument), (void**) aInstancePtrResult);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsImageDocument::nsImageDocument()
|
||||
{
|
||||
#ifndef USE_IMG2
|
||||
mImageRequest = nsnull;
|
||||
#endif
|
||||
mBlack = NS_RGB(0, 0, 0);
|
||||
}
|
||||
|
||||
nsImageDocument::~nsImageDocument()
|
||||
{
|
||||
#ifndef USE_IMG2
|
||||
NS_IF_RELEASE(mImageRequest);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset)
|
||||
{
|
||||
NS_ASSERTION(aDocListener, "null aDocListener");
|
||||
|
||||
nsresult rv = Init();
|
||||
|
||||
if (NS_FAILED(rv) && rv != NS_ERROR_ALREADY_INITIALIZED) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = nsDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup,
|
||||
aContainer, aDocListener, aReset);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create synthetic document
|
||||
rv = CreateSyntheticDocument();
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aDocListener = new ImageListener(this);
|
||||
if (!*aDocListener)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*aDocListener);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef USE_IMG2
|
||||
nsresult
|
||||
nsImageDocument::StartImageLoad(nsIURI* aURL, nsIStreamListener*& aListener)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
aListener = nsnull;
|
||||
|
||||
// Tell image group to load the stream now. This will get the image
|
||||
// hooked up to the open stream and return the underlying listener
|
||||
// so that we can pass it back upwards.
|
||||
|
||||
|
||||
nsIPresShell* shell = GetShellAt(0);
|
||||
if (nsnull != shell) {
|
||||
nsCOMPtr<nsIPresContext> cx;
|
||||
shell->GetPresContext(getter_AddRefs(cx));
|
||||
if (cx) {
|
||||
nsIImageGroup* group = nsnull;
|
||||
cx->GetImageGroup(&group);
|
||||
if (nsnull != group) {
|
||||
|
||||
char* spec;
|
||||
(void)aURL->GetSpec(&spec);
|
||||
nsIStreamListener* listener = nsnull;
|
||||
rv = group->GetImageFromStream(spec, nsnull, nsnull,
|
||||
0, 0, 0,
|
||||
mImageRequest, listener);
|
||||
|
||||
//set flag to indicate view-image needs to use imgcache
|
||||
group->SetImgLoadAttributes(nsImageLoadFlags_kSticky);
|
||||
|
||||
nsCRT::free(spec);
|
||||
aListener = listener;
|
||||
NS_RELEASE(group);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
|
||||
// Finally, start the layout going
|
||||
StartLayout();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsImageDocument::CreateSyntheticDocument()
|
||||
{
|
||||
// Synthesize an html document that refers to the image
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::html, nsnull,
|
||||
kNameSpaceID_None,
|
||||
*getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIHTMLContent* root;
|
||||
rv = NS_NewHTMLHtmlElement(&root, nodeInfo);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
root->SetDocument(this, PR_FALSE, PR_TRUE);
|
||||
SetRootContent(root);
|
||||
|
||||
rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::body, nsnull,
|
||||
kNameSpaceID_None,
|
||||
*getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIHTMLContent* body;
|
||||
rv = NS_NewHTMLBodyElement(&body, nodeInfo);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
body->SetDocument(this, PR_FALSE, PR_TRUE);
|
||||
|
||||
rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::p, nsnull, kNameSpaceID_None,
|
||||
*getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIHTMLContent* center;
|
||||
rv = NS_NewHTMLParagraphElement(¢er, nodeInfo);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
center->SetDocument(this, PR_FALSE, PR_TRUE);
|
||||
|
||||
rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::img, nsnull,
|
||||
kNameSpaceID_None,
|
||||
*getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIHTMLContent* image;
|
||||
rv = NS_NewHTMLImageElement(&image, nodeInfo);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
image->SetDocument(this, PR_FALSE, PR_TRUE);
|
||||
|
||||
char* src;
|
||||
mDocumentURL->GetSpec(&src);
|
||||
|
||||
nsString src_string; src_string.AssignWithConversion(src);
|
||||
nsHTMLValue val(src_string);
|
||||
delete[] src;
|
||||
image->SetHTMLAttribute(nsHTMLAtoms::src, val, PR_FALSE);
|
||||
image->SetHTMLAttribute(nsHTMLAtoms::alt, val, PR_FALSE);
|
||||
|
||||
root->AppendChildTo(body, PR_FALSE);
|
||||
center->AppendChildTo(image, PR_FALSE);
|
||||
body->AppendChildTo(center, PR_FALSE);
|
||||
|
||||
NS_RELEASE(image);
|
||||
NS_RELEASE(center);
|
||||
NS_RELEASE(body);
|
||||
NS_RELEASE(root);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsImageDocument::StartLayout()
|
||||
{
|
||||
PRInt32 i, ns = GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsIPresShell* shell = GetShellAt(i);
|
||||
if (nsnull != shell) {
|
||||
// Make shell an observer for next time
|
||||
shell->BeginObservingDocument();
|
||||
|
||||
// Resize-reflow this time
|
||||
nsCOMPtr<nsIPresContext> cx;
|
||||
shell->GetPresContext(getter_AddRefs(cx));
|
||||
nsRect r;
|
||||
cx->GetVisibleArea(r);
|
||||
shell->InitialReflow(r.width, r.height);
|
||||
|
||||
// Now trigger a refresh
|
||||
// XXX It's unfortunate that this has to be here
|
||||
nsCOMPtr<nsIViewManager> vm;
|
||||
shell->GetViewManager(getter_AddRefs(vm));
|
||||
if (vm) {
|
||||
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||
}
|
||||
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImageDocument::EndLayout(nsISupports *ctxt,
|
||||
nsresult status,
|
||||
const PRUnichar *errorMsg)
|
||||
{
|
||||
// Layout has completed: now update the title
|
||||
UpdateTitle();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// NOTE: call this AFTER the shell has been installed as an observer of the
|
||||
// document so the update notification gets processed by the shell
|
||||
// and it updates the titlebar
|
||||
nsresult nsImageDocument::UpdateTitle( void )
|
||||
{
|
||||
#ifdef USE_EXTENSION_FOR_TYPE
|
||||
// XXX TEMPORARY XXX
|
||||
// We want to display the image type, however there is no way to right now
|
||||
// so instead we just get the image-extension
|
||||
// - get the URL interface, get the extension, convert to upper-case
|
||||
// Unless the Imagerequest or Image can tell us the type this is the best we can do.
|
||||
nsIURL *pURL=nsnull;
|
||||
if(NS_SUCCEEDED(mDocumentURL->QueryInterface(NS_GET_IID(nsIURL),(void **)&pURL))){
|
||||
char *pExtension=nsnull;
|
||||
pURL->GetFileExtension(&pExtension);
|
||||
if(pExtension){
|
||||
nsString strExt; strExt.AssignWithConversion(pExtension);
|
||||
strExt.ToUpperCase();
|
||||
titleStr.Append(strExt);
|
||||
nsCRT::free(pExtension);
|
||||
pExtension=nsnull;
|
||||
}
|
||||
NS_IF_RELEASE(pURL);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
nsresult rv;
|
||||
// Create a bundle for the localization
|
||||
NS_WITH_SERVICE(nsIStringBundleService, stringService, kStringBundleServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && stringService) {
|
||||
nsCOMPtr<nsILocale> locale = nsnull;
|
||||
rv = stringService->CreateBundle(NSIMAGEDOCUMENT_PROPERTIES_URI, locale, getter_AddRefs(bundle));
|
||||
}
|
||||
// XXX this shouldn't be ifndef'd
|
||||
#ifndef USE_IMG2
|
||||
if (NS_SUCCEEDED(rv) && bundle) {
|
||||
nsAutoString key;
|
||||
nsXPIDLString valUni;
|
||||
if (mImageRequest) {
|
||||
PRUint32 width, height;
|
||||
mImageRequest->GetNaturalDimensions(&width, &height);
|
||||
// if we got a valid size (sometimes we do not) then display it
|
||||
if (width != 0 && height != 0){
|
||||
key.AssignWithConversion("ImageTitleWithDimensions");
|
||||
nsAutoString widthStr; widthStr.AppendInt(width);
|
||||
nsAutoString heightStr; heightStr.AppendInt(height);
|
||||
const PRUnichar *formatStrings[2] = {widthStr.GetUnicode(), heightStr.GetUnicode()};
|
||||
rv = bundle->FormatStringFromName(key.GetUnicode(), formatStrings, 2, getter_Copies(valUni));
|
||||
}
|
||||
}
|
||||
if (nsLiteralString(valUni).IsEmpty()) {
|
||||
key.AssignWithConversion("ImageTitleWithoutDimensions");
|
||||
rv = bundle->GetStringFromName(key.GetUnicode(), getter_Copies(valUni));
|
||||
}
|
||||
if (NS_SUCCEEDED(rv) && valUni) {
|
||||
nsString titleStr;
|
||||
titleStr.Assign(valUni);
|
||||
// set it on the document
|
||||
SetTitle(titleStr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
300
mozilla/content/shared/public/nsHTMLAtomList.h
Normal file
300
mozilla/content/shared/public/nsHTMLAtomList.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/******
|
||||
|
||||
This file contains the list of all HTML atoms
|
||||
See nsHTMLAtoms.h for access to the atoms
|
||||
|
||||
It is designed to be used as inline input to nsHTMLAtoms.cpp *only*
|
||||
through the magic of C preprocessing.
|
||||
|
||||
All entires must be enclosed in the macro HTML_ATOM which will have cruel
|
||||
and unusual things done to it
|
||||
|
||||
The first argument to HTML_ATOM is the C++ name of the atom
|
||||
The second argument it HTML_ATOM is the string value of the atom
|
||||
|
||||
******/
|
||||
|
||||
HTML_ATOM(mozAnonymousBlock, ":-moz-anonymous-block")
|
||||
HTML_ATOM(mozAnonymousPositionedBlock, ":-moz-anonymous-positioned-block")
|
||||
HTML_ATOM(mozFirstLineFixup, ":-moz-first-line-fixup")
|
||||
HTML_ATOM(mozLetterFrame, ":-moz-letter-frame")
|
||||
HTML_ATOM(mozLineFrame, ":-moz-line-frame")
|
||||
HTML_ATOM(mozListBulletPseudo, ":-moz-list-bullet")
|
||||
HTML_ATOM(mozSingleLineTextControlFrame, ":-moz-singleline-textcontrol-frame")
|
||||
HTML_ATOM(mozFocusInnerPseudo, ":-moz-focus-inner")
|
||||
HTML_ATOM(mozFocusOuterPseudo, ":-moz-focus-outer")
|
||||
HTML_ATOM(mozDisplayComboboxControlFrame, ":-moz-display-comboboxcontrol-frame")
|
||||
|
||||
HTML_ATOM(_baseHref, NS_HTML_BASE_HREF)
|
||||
HTML_ATOM(_baseTarget, NS_HTML_BASE_TARGET)
|
||||
HTML_ATOM(a, "a")
|
||||
HTML_ATOM(abbr, "abbr")
|
||||
HTML_ATOM(above, "above")
|
||||
HTML_ATOM(accept, "accept")
|
||||
HTML_ATOM(acceptcharset, "accept-charset")
|
||||
HTML_ATOM(accesskey, "accesskey")
|
||||
HTML_ATOM(action, "action")
|
||||
HTML_ATOM(align, "align")
|
||||
HTML_ATOM(alink, "alink")
|
||||
HTML_ATOM(alt, "alt")
|
||||
HTML_ATOM(applet, "applet")
|
||||
HTML_ATOM(archive, "archive")
|
||||
HTML_ATOM(area, "area")
|
||||
HTML_ATOM(axis, "axis")
|
||||
HTML_ATOM(background, "background")
|
||||
HTML_ATOM(below, "below")
|
||||
HTML_ATOM(bgcolor, "bgcolor")
|
||||
HTML_ATOM(blockquote, "blockquote")
|
||||
HTML_ATOM(body, "body")
|
||||
HTML_ATOM(border, "border")
|
||||
HTML_ATOM(bordercolor, "bordercolor")
|
||||
HTML_ATOM(bottompadding, "bottompadding")
|
||||
HTML_ATOM(br, "br")
|
||||
HTML_ATOM(b, "b")
|
||||
HTML_ATOM(button, "button")
|
||||
HTML_ATOM(buttonContentPseudo, ":button-content")
|
||||
HTML_ATOM(caption, "caption")
|
||||
HTML_ATOM(cellContentPseudo, ":cell-content")
|
||||
HTML_ATOM(cellpadding, "cellpadding")
|
||||
HTML_ATOM(cellspacing, "cellspacing")
|
||||
HTML_ATOM(ch, "ch")
|
||||
HTML_ATOM(_char, "char")
|
||||
HTML_ATOM(charoff, "charoff")
|
||||
HTML_ATOM(charset, "charset")
|
||||
HTML_ATOM(checked, "checked")
|
||||
HTML_ATOM(choff, "choff")
|
||||
HTML_ATOM(cite, "cite")
|
||||
HTML_ATOM(kClass, "class")
|
||||
HTML_ATOM(classid, "classid")
|
||||
HTML_ATOM(clear, "clear")
|
||||
HTML_ATOM(clip, "clip")
|
||||
HTML_ATOM(code, "code")
|
||||
HTML_ATOM(codebase, "codebase")
|
||||
HTML_ATOM(codetype, "codetype")
|
||||
HTML_ATOM(color, "color")
|
||||
HTML_ATOM(col, "col")
|
||||
HTML_ATOM(colgroup, "colgroup")
|
||||
HTML_ATOM(cols, "cols")
|
||||
HTML_ATOM(colspan, "colspan")
|
||||
HTML_ATOM(combobox, "combobox")
|
||||
HTML_ATOM(columnPseudo, ":body-column")
|
||||
HTML_ATOM(commentPseudo, ":-moz-comment")
|
||||
HTML_ATOM(compact, "compact")
|
||||
HTML_ATOM(content, "content")
|
||||
HTML_ATOM(coords, "coords")
|
||||
HTML_ATOM(dd, "dd")
|
||||
HTML_ATOM(defaultchecked, "defaultchecked")
|
||||
HTML_ATOM(defaultselected, "defaultselected")
|
||||
HTML_ATOM(defaultvalue, "defaultvalue")
|
||||
HTML_ATOM(declare, "declare")
|
||||
HTML_ATOM(defer, "defer")
|
||||
HTML_ATOM(dir, "dir")
|
||||
HTML_ATOM(div, "div")
|
||||
HTML_ATOM(disabled, "disabled")
|
||||
HTML_ATOM(dl, "dl")
|
||||
HTML_ATOM(dropDownListPseudo, ":-moz-dropdown-list")
|
||||
HTML_ATOM(dt, "dt")
|
||||
|
||||
HTML_ATOM(datetime, "datetime")
|
||||
HTML_ATOM(data, "data")
|
||||
HTML_ATOM(dfn, "dfn")
|
||||
HTML_ATOM(em, "em")
|
||||
HTML_ATOM(embed, "embed")
|
||||
HTML_ATOM(encoding, "encoding")
|
||||
HTML_ATOM(enctype, "enctype")
|
||||
HTML_ATOM(face, "face")
|
||||
HTML_ATOM(fieldset, "fieldset")
|
||||
HTML_ATOM(fieldsetContentPseudo, ":fieldset-content")
|
||||
HTML_ATOM(firstLetterPseudo, ":first-letter")
|
||||
HTML_ATOM(firstLinePseudo, ":first-line")
|
||||
HTML_ATOM(font, "font")
|
||||
HTML_ATOM(fontWeight, "font-weight")
|
||||
HTML_ATOM(_for, "for")
|
||||
HTML_ATOM(form, "form")
|
||||
HTML_ATOM(frame, "frame")
|
||||
HTML_ATOM(frameborder, "frameborder")
|
||||
HTML_ATOM(frameset, "frameset")
|
||||
HTML_ATOM(framesetBlankPseudo, ":frameset-blank")
|
||||
HTML_ATOM(gutter, "gutter")
|
||||
HTML_ATOM(h1, "h1")
|
||||
HTML_ATOM(h2, "h2")
|
||||
HTML_ATOM(h3, "h3")
|
||||
HTML_ATOM(h4, "h4")
|
||||
HTML_ATOM(h5, "h5")
|
||||
HTML_ATOM(h6, "h6")
|
||||
HTML_ATOM(head, "head")
|
||||
HTML_ATOM(headerContentBase, "content-base")
|
||||
HTML_ATOM(headerContentLanguage, "content-language")
|
||||
HTML_ATOM(headerContentScriptType, "content-script-type")
|
||||
HTML_ATOM(headerContentStyleType, "content-style-type")
|
||||
HTML_ATOM(headerContentType, "content-type")
|
||||
HTML_ATOM(headerDefaultStyle, "default-style")
|
||||
HTML_ATOM(headerWindowTarget, "window-target")
|
||||
HTML_ATOM(headers, "headers")
|
||||
HTML_ATOM(height, "height")
|
||||
HTML_ATOM(hidden, "hidden")
|
||||
HTML_ATOM(horizontalFramesetBorderPseudo, ":hframeset-border")
|
||||
HTML_ATOM(hr, "hr")
|
||||
HTML_ATOM(href, "href")
|
||||
HTML_ATOM(hreflang, "hreflang")
|
||||
HTML_ATOM(hspace, "hspace")
|
||||
HTML_ATOM(html, "html")
|
||||
HTML_ATOM(httpEquiv, "http-equiv")
|
||||
HTML_ATOM(ibPseudo, ":ib-pseudo")
|
||||
HTML_ATOM(i, "i")
|
||||
HTML_ATOM(id, "id")
|
||||
HTML_ATOM(iframe, "iframe")
|
||||
HTML_ATOM(ilayer, "ilayer")
|
||||
HTML_ATOM(img, "img")
|
||||
HTML_ATOM(index, "index")
|
||||
HTML_ATOM(input, "input")
|
||||
HTML_ATOM(isindex, "isindex")
|
||||
HTML_ATOM(ismap, "ismap")
|
||||
HTML_ATOM(label, "label")
|
||||
HTML_ATOM(labelContentPseudo, ":label-content")
|
||||
HTML_ATOM(lang, "lang")
|
||||
HTML_ATOM(layer, "layer")
|
||||
HTML_ATOM(layout, "layout")
|
||||
HTML_ATOM(li, "li")
|
||||
HTML_ATOM(link, "link")
|
||||
HTML_ATOM(left, "left")
|
||||
HTML_ATOM(leftpadding, "leftpadding")
|
||||
HTML_ATOM(legend, "legend")
|
||||
HTML_ATOM(legendContentPseudo, ":legend-content")
|
||||
HTML_ATOM(length, "length")
|
||||
HTML_ATOM(longdesc, "longdesc")
|
||||
HTML_ATOM(lowsrc, "lowsrc")
|
||||
HTML_ATOM(marginheight, "marginheight")
|
||||
HTML_ATOM(marginwidth, "marginwidth")
|
||||
HTML_ATOM(maxlength, "maxlength")
|
||||
HTML_ATOM(mayscript, "mayscript")
|
||||
HTML_ATOM(media, "media")
|
||||
HTML_ATOM(menu, "menu")
|
||||
HTML_ATOM(meta, "meta")
|
||||
HTML_ATOM(method, "method")
|
||||
HTML_ATOM(multicol, "multicol")
|
||||
HTML_ATOM(multiple, "multiple")
|
||||
HTML_ATOM(name, "name")
|
||||
HTML_ATOM(nohref, "nohref")
|
||||
HTML_ATOM(noresize, "noresize")
|
||||
HTML_ATOM(noscript, "noscript")
|
||||
HTML_ATOM(noshade, "noshade")
|
||||
HTML_ATOM(nowrap, "nowrap")
|
||||
HTML_ATOM(object, "object")
|
||||
HTML_ATOM(ol, "ol")
|
||||
HTML_ATOM(option, "option")
|
||||
HTML_ATOM(overflow, "overflow")
|
||||
HTML_ATOM(p, "p")
|
||||
HTML_ATOM(pagex, "pagex")
|
||||
HTML_ATOM(pagey, "pagey")
|
||||
HTML_ATOM(param, "param")
|
||||
HTML_ATOM(placeholderPseudo, ":placeholder-frame")
|
||||
HTML_ATOM(pointSize, "point-size")
|
||||
HTML_ATOM(pre, "pre")
|
||||
HTML_ATOM(processingInstructionPseudo, ":-moz-pi")
|
||||
HTML_ATOM(profile, "profile")
|
||||
HTML_ATOM(prompt, "prompt")
|
||||
HTML_ATOM(radioPseudo, ":-moz-radio")
|
||||
HTML_ATOM(checkPseudo, ":-moz-checkbox")
|
||||
HTML_ATOM(readonly, "readonly")
|
||||
HTML_ATOM(rel, "rel")
|
||||
HTML_ATOM(repeat, "repeat")
|
||||
HTML_ATOM(rev, "rev")
|
||||
HTML_ATOM(rightpadding, "rightpadding")
|
||||
HTML_ATOM(rows, "rows")
|
||||
HTML_ATOM(rowspan, "rowspan")
|
||||
HTML_ATOM(rules, "rules")
|
||||
HTML_ATOM(s, "s")
|
||||
HTML_ATOM(scheme, "scheme")
|
||||
HTML_ATOM(scope, "scope")
|
||||
HTML_ATOM(script, "script")
|
||||
HTML_ATOM(scrolling, "scrolling")
|
||||
HTML_ATOM(select, "select")
|
||||
HTML_ATOM(selected, "selected")
|
||||
HTML_ATOM(selectedindex, "selectedindex")
|
||||
HTML_ATOM(shape, "shape")
|
||||
HTML_ATOM(size, "size")
|
||||
HTML_ATOM(spacer, "spacer")
|
||||
HTML_ATOM(span, "span")
|
||||
HTML_ATOM(src, "src")
|
||||
HTML_ATOM(standby, "standby")
|
||||
HTML_ATOM(start, "start")
|
||||
HTML_ATOM(strike, "strike")
|
||||
HTML_ATOM(strong, "strong")
|
||||
HTML_ATOM(style, "style")
|
||||
HTML_ATOM(summary, "summary")
|
||||
HTML_ATOM(suppress, "suppress")
|
||||
HTML_ATOM(tabindex, "tabindex")
|
||||
HTML_ATOM(table, "table")
|
||||
HTML_ATOM(tablePseudo, ":table")
|
||||
HTML_ATOM(tableCellPseudo, ":table-cell")
|
||||
HTML_ATOM(tableColGroupPseudo, ":table-column-group")
|
||||
HTML_ATOM(tableColPseudo, ":table-column")
|
||||
HTML_ATOM(tableOuterPseudo, ":table-outer")
|
||||
HTML_ATOM(tableRowGroupPseudo, ":table-row-group")
|
||||
HTML_ATOM(tableRowPseudo, ":table-row")
|
||||
HTML_ATOM(tabstop, "tabstop")
|
||||
HTML_ATOM(target, "target")
|
||||
HTML_ATOM(tbody, "tbody")
|
||||
HTML_ATOM(td, "td")
|
||||
HTML_ATOM(tfoot, "tfoot")
|
||||
HTML_ATOM(thead, "thead")
|
||||
HTML_ATOM(text, "text")
|
||||
HTML_ATOM(textarea, "textarea")
|
||||
HTML_ATOM(textPseudo, ":-moz-text")
|
||||
HTML_ATOM(th, "th")
|
||||
HTML_ATOM(title, "title")
|
||||
HTML_ATOM(top, "top")
|
||||
HTML_ATOM(toppadding, "toppadding")
|
||||
HTML_ATOM(tr, "tr")
|
||||
HTML_ATOM(tt, "tt")
|
||||
HTML_ATOM(type, "type")
|
||||
HTML_ATOM(u, "u")
|
||||
HTML_ATOM(ul, "ul")
|
||||
HTML_ATOM(usemap, "usemap")
|
||||
HTML_ATOM(valign, "valign")
|
||||
HTML_ATOM(value, "value")
|
||||
HTML_ATOM(valuetype, "valuetype")
|
||||
HTML_ATOM(variable, "variable")
|
||||
HTML_ATOM(vcard_name, "vcard_name")
|
||||
HTML_ATOM(version, "version")
|
||||
HTML_ATOM(verticalFramesetBorderPseudo, ":vframeset-border")
|
||||
HTML_ATOM(visibility, "visibility")
|
||||
HTML_ATOM(vlink, "vlink")
|
||||
HTML_ATOM(vspace, "vspace")
|
||||
HTML_ATOM(wbr, "wbr")
|
||||
HTML_ATOM(width, "width")
|
||||
HTML_ATOM(wrap, "wrap")
|
||||
HTML_ATOM(wrappedFramePseudo, ":wrapped-frame")
|
||||
HTML_ATOM(zindex, "zindex")
|
||||
HTML_ATOM(z_index, "z-index")
|
||||
|
||||
HTML_ATOM(moz_tristate, "moz-tristate")
|
||||
HTML_ATOM(moz_tristatevalue, "moz-tristatevalue")
|
||||
|
||||
#ifdef DEBUG
|
||||
HTML_ATOM(iform, "IForm")
|
||||
HTML_ATOM(form_control_list, "FormControlList")
|
||||
#endif
|
||||
54
mozilla/content/shared/public/nsHTMLAtoms.h
Normal file
54
mozilla/content/shared/public/nsHTMLAtoms.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
#ifndef nsHTMLAtoms_h___
|
||||
#define nsHTMLAtoms_h___
|
||||
|
||||
#include "nsIAtom.h"
|
||||
|
||||
#define NS_HTML_BASE_HREF "_base_href"
|
||||
#define NS_HTML_BASE_TARGET "_base_target"
|
||||
|
||||
/**
|
||||
* This class wraps up the creation (and destruction) of the standard
|
||||
* set of html atoms used during normal html handling. This objects
|
||||
* are created when the first html content object is created and they
|
||||
* are destroyed when the last html content object is destroyed.
|
||||
*/
|
||||
class nsHTMLAtoms {
|
||||
public:
|
||||
|
||||
static void AddRefAtoms();
|
||||
static void ReleaseAtoms();
|
||||
|
||||
/* Declare all atoms
|
||||
|
||||
The atom names and values are stored in nsHTMLAtomList.h and
|
||||
are brought to you by the magic of C preprocessing
|
||||
|
||||
Add new atoms to nsHTMLAtomList and all support logic will be auto-generated
|
||||
*/
|
||||
#define HTML_ATOM(_name, _value) static nsIAtom* _name;
|
||||
#include "nsHTMLAtomList.h"
|
||||
#undef HTML_ATOM
|
||||
};
|
||||
|
||||
#endif /* nsHTMLAtoms_h___ */
|
||||
52
mozilla/content/shared/src/nsHTMLAtoms.cpp
Normal file
52
mozilla/content/shared/src/nsHTMLAtoms.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- 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 "nsHTMLAtoms.h"
|
||||
|
||||
// define storage for all atoms
|
||||
#define HTML_ATOM(_name, _value) nsIAtom* nsHTMLAtoms::_name;
|
||||
#include "nsHTMLAtomList.h"
|
||||
#undef HTML_ATOM
|
||||
|
||||
|
||||
static nsrefcnt gRefCnt;
|
||||
|
||||
void nsHTMLAtoms::AddRefAtoms()
|
||||
{
|
||||
if (0 == gRefCnt++) {
|
||||
// create atoms
|
||||
#define HTML_ATOM(_name, _value) _name = NS_NewAtom(_value);
|
||||
#include "nsHTMLAtomList.h"
|
||||
#undef HTML_ATOM
|
||||
}
|
||||
}
|
||||
|
||||
void nsHTMLAtoms::ReleaseAtoms()
|
||||
{
|
||||
NS_PRECONDITION(gRefCnt != 0, "bad release atoms");
|
||||
if (--gRefCnt == 0) {
|
||||
// release atoms
|
||||
#define HTML_ATOM(_name, _value) NS_RELEASE(_name);
|
||||
#include "nsHTMLAtomList.h"
|
||||
#undef HTML_ATOM
|
||||
}
|
||||
}
|
||||
|
||||
36
mozilla/gfx/Makefile.in
Normal file
36
mozilla/gfx/Makefile.in
Normal file
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
9
mozilla/gfx/idl/MANIFEST_IDL
Normal file
9
mozilla/gfx/idl/MANIFEST_IDL
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:widget directory
|
||||
#
|
||||
|
||||
nsIFontEnumerator.idl
|
||||
nsIScriptableRegion.idl
|
||||
nsIScreen.idl
|
||||
nsIScreenManager.idl
|
||||
nsIPrintOptions.idl
|
||||
42
mozilla/gfx/idl/Makefile.in
Normal file
42
mozilla/gfx/idl/Makefile.in
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# 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 = layout
|
||||
XPIDL_MODULE = gfx
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIFontEnumerator.idl \
|
||||
nsIScriptableRegion.idl \
|
||||
nsIGraphics.idl \
|
||||
nsIScreen.idl \
|
||||
nsIScreenManager.idl \
|
||||
nsIPrintOptions.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
89
mozilla/gfx/idl/geniid.pl
Normal file
89
mozilla/gfx/idl/geniid.pl
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/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);
|
||||
}
|
||||
41
mozilla/gfx/idl/makefile.win
Normal file
41
mozilla/gfx/idl/makefile.win
Normal file
@@ -0,0 +1,41 @@
|
||||
#!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=raptor
|
||||
XPIDL_MODULE=gfx
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIFontEnumerator.idl \
|
||||
.\nsIScriptableRegion.idl \
|
||||
.\nsIScreen.idl \
|
||||
.\nsIScreenManager.idl \
|
||||
.\nsIPrintOptions.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
55
mozilla/gfx/idl/nsIFontEnumerator.idl
Normal file
55
mozilla/gfx/idl/nsIFontEnumerator.idl
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- 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);
|
||||
};
|
||||
76
mozilla/gfx/idl/nsIGraphics.idl
Executable file
76
mozilla/gfx/idl/nsIGraphics.idl
Executable file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#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();
|
||||
};
|
||||
156
mozilla/gfx/idl/nsIPrintOptions.idl
Normal file
156
mozilla/gfx/idl/nsIPrintOptions.idl
Normal file
@@ -0,0 +1,156 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Don Cone <dcone@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsMargin.h"
|
||||
#include "nsFont.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* Native types
|
||||
*/
|
||||
[ref] native nsNativeMarginRef(nsMargin);
|
||||
[ref] native nsNativeFontRef(nsFont);
|
||||
[ref] native nsNativeStringRef(nsString);
|
||||
|
||||
/**
|
||||
* Simplified graphics interface for JS rendering.
|
||||
*/
|
||||
[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 kOptPrintDocTitle = 0x00000004;
|
||||
const long kOptPrintDocLoc = 0x00000008;
|
||||
const long kOptPrintPageNums = 0x00000010;
|
||||
const long kOptPrintPageTotal = 0x00000020;
|
||||
const long kOptPrintDatePrinted = 0x00000040;
|
||||
const long kPrintOptionsEnableSelectionRB = 0x00000080;
|
||||
|
||||
/* 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
|
||||
*/
|
||||
const short kLetterPaperSize = 0;
|
||||
const short kLegalPaperSize = 1;
|
||||
const short kExecutivePaperSize = 2;
|
||||
const short kA4PaperSize = 3;
|
||||
|
||||
/**
|
||||
* Print Frame Constants
|
||||
*/
|
||||
const short kFramesAsIs = 0;
|
||||
const short kSelectedFrame = 1;
|
||||
const short kEachFrameSep = 2;
|
||||
|
||||
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();
|
||||
|
||||
|
||||
/**
|
||||
* 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 short printRange;
|
||||
attribute short pageNumJust;
|
||||
attribute wstring title;
|
||||
attribute wstring docURL;
|
||||
|
||||
attribute short howToEnableFrameUI;
|
||||
attribute short printFrameType;
|
||||
|
||||
/* Additional XP Related */
|
||||
attribute boolean printReversed;
|
||||
attribute boolean printInColor; /* a false means grayscale */
|
||||
attribute long paperSize; /* see page size consts */
|
||||
attribute wstring printCommand;
|
||||
attribute boolean printToFile;
|
||||
attribute wstring toFileName;
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
};
|
||||
139
mozilla/gfx/idl/nsIPrintSettings.idl
Normal file
139
mozilla/gfx/idl/nsIPrintSettings.idl
Normal file
@@ -0,0 +1,139 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Don Cone <dcone@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsMargin.h"
|
||||
#include "nsFont.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* Native types
|
||||
*/
|
||||
[ref] native nsNativeMarginRef(nsMargin);
|
||||
[ref] native nsNativeFontRef(nsFont);
|
||||
[ref] native nsNativeStringRef(nsString);
|
||||
|
||||
/**
|
||||
* Simplified graphics interface for JS rendering.
|
||||
*/
|
||||
[scriptable, uuid(83427530-F790-11d4-A869-00105A183419)]
|
||||
|
||||
|
||||
|
||||
interface nsIPrintSettings : nsISupports
|
||||
{
|
||||
/* Print Option Flags for Bit Field*/
|
||||
const long kOptPrintOddPages = 0x00000001;
|
||||
const long kOptPrintEvenPages = 0x00000002;
|
||||
const long kOptPrintDocTitle = 0x00000004;
|
||||
const long kOptPrintDocLoc = 0x00000008;
|
||||
const long kOptPrintPageNums = 0x00000010;
|
||||
const long kOptPrintPageTotal = 0x00000020;
|
||||
const long kOptPrintDatePrinted = 0x00000040;
|
||||
const long kPrintOptionsEnableSelectionRB = 0x00000080;
|
||||
|
||||
/* 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
|
||||
*/
|
||||
const short kLetterPaperSize = 0;
|
||||
const short kLegalPaperSize = 1;
|
||||
const short kExecutivePaperSize = 2;
|
||||
const short kA4PaperSize = 3;
|
||||
|
||||
/**
|
||||
* Print Frame Constants
|
||||
*/
|
||||
const short kFramesAsIs = 0;
|
||||
const short kSelectedFrame = 1;
|
||||
const short kEachFrameSep = 2;
|
||||
|
||||
|
||||
/**
|
||||
* Set PrintOptions
|
||||
*/
|
||||
void SetPrintOptions(in PRInt32 aType, in PRBool aTurnOnOff);
|
||||
|
||||
/**
|
||||
* Get PrintOptions
|
||||
*/
|
||||
PRBool GetPrintOptions(in PRInt32 aType);
|
||||
|
||||
/**
|
||||
* Set PrintOptions Bit field
|
||||
*/
|
||||
PRInt32 GetPrintOptionsBits();
|
||||
|
||||
|
||||
/**
|
||||
* Data Members
|
||||
*/
|
||||
attribute long startPageRange;
|
||||
attribute long endPageRange;
|
||||
|
||||
attribute boolean printReversed;
|
||||
attribute boolean printInColor; /* a false means grayscale */
|
||||
attribute long paperSize; /* see page size consts */
|
||||
attribute wstring printCommand;
|
||||
attribute boolean printToFile;
|
||||
attribute wstring toFileName;
|
||||
|
||||
attribute double marginTop; /* these are in inches */
|
||||
attribute double marginLeft;
|
||||
attribute double marginBottom;
|
||||
attribute double marginRight;
|
||||
|
||||
attribute long printRange;
|
||||
attribute long pageNumJust;
|
||||
attribute wstring title;
|
||||
attribute wstring docURL;
|
||||
|
||||
attribute boolean isPrintFrame;
|
||||
attribute long printFrameType;
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
};
|
||||
38
mozilla/gfx/idl/nsIScreen.idl
Normal file
38
mozilla/gfx/idl/nsIScreen.idl
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- 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++
|
||||
|
||||
%}
|
||||
49
mozilla/gfx/idl/nsIScreenManager.idl
Normal file
49
mozilla/gfx/idl/nsIScreenManager.idl
Normal file
@@ -0,0 +1,49 @@
|
||||
/* -*- 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++
|
||||
|
||||
%}
|
||||
181
mozilla/gfx/idl/nsIScriptableRegion.idl
Normal file
181
mozilla/gfx/idl/nsIScriptableRegion.idl
Normal file
@@ -0,0 +1,181 @@
|
||||
/* -*- 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"
|
||||
|
||||
[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 ) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
25
mozilla/gfx/macbuild/GFXSharedDebugPrefix.h
Normal file
25
mozilla/gfx/macbuild/GFXSharedDebugPrefix.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#define _IMPL_NS_GFX 1
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
25
mozilla/gfx/macbuild/GFXSharedPrefix.h
Normal file
25
mozilla/gfx/macbuild/GFXSharedPrefix.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#define _IMPL_NS_GFX 1
|
||||
|
||||
#include "MacSharedPrefix.h"
|
||||
25
mozilla/gfx/macbuild/GFXStaticDebugPrefix.h
Normal file
25
mozilla/gfx/macbuild/GFXStaticDebugPrefix.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#define GFX_STATIC 1
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
25
mozilla/gfx/macbuild/GFXStaticPrefix.h
Normal file
25
mozilla/gfx/macbuild/GFXStaticPrefix.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#define GFX_STATIC 1
|
||||
|
||||
#include "MacPrefix.h"
|
||||
BIN
mozilla/gfx/macbuild/gfx.mcp
Normal file
BIN
mozilla/gfx/macbuild/gfx.mcp
Normal file
Binary file not shown.
BIN
mozilla/gfx/macbuild/gfxIDL.mcp
Normal file
BIN
mozilla/gfx/macbuild/gfxIDL.mcp
Normal file
Binary file not shown.
30
mozilla/gfx/makefile.win
Normal file
30
mozilla/gfx/makefile.win
Normal file
@@ -0,0 +1,30 @@
|
||||
#!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>
|
||||
31
mozilla/gfx/public/MANIFEST
Normal file
31
mozilla/gfx/public/MANIFEST
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# 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
|
||||
nsIImageManager.h
|
||||
nsIImageGroup.h
|
||||
nsIImageRequest.h
|
||||
nsIImageObserver.h
|
||||
nsIDeviceContext.h
|
||||
nsIImage.h
|
||||
nsIBlender.h
|
||||
nsGfxCIID.h
|
||||
nsIRegion.h
|
||||
nsDeviceContext.h
|
||||
nsRenderingContextImpl.h
|
||||
nsIDeviceContextSpec.h
|
||||
nsIDeviceContextSpecFactory.h
|
||||
nsIDrawingSurface.h
|
||||
nsRepeater.h
|
||||
64
mozilla/gfx/public/Makefile.in
Normal file
64
mozilla/gfx/public/Makefile.in
Normal file
@@ -0,0 +1,64 @@
|
||||
#
|
||||
# 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 = layout
|
||||
|
||||
EXPORTS = \
|
||||
nsColor.h \
|
||||
nsColorNames.h \
|
||||
nsColorNameList.h \
|
||||
nsCoord.h \
|
||||
nsFont.h \
|
||||
nsRect.h \
|
||||
nsRepeater.h \
|
||||
nsPoint.h \
|
||||
nsSize.h \
|
||||
nsMargin.h \
|
||||
nsTransform2D.h \
|
||||
nsIRenderingContext.h \
|
||||
nsRenderingContextImpl.h \
|
||||
nsIFontMetrics.h \
|
||||
nsIImageManager.h \
|
||||
nsIImageGroup.h \
|
||||
nsIImageRequest.h \
|
||||
nsIImageObserver.h \
|
||||
nsIDeviceContext.h \
|
||||
nsIImage.h \
|
||||
nsIBlender.h \
|
||||
nsGfxCIID.h \
|
||||
nsIRegion.h \
|
||||
nsDeviceContext.h \
|
||||
nsIDeviceContextSpec.h \
|
||||
nsIDeviceContextSpecFactory.h \
|
||||
nsIDrawingSurface.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
57
mozilla/gfx/public/makefile.win
Normal file
57
mozilla/gfx/public/makefile.win
Normal file
@@ -0,0 +1,57 @@
|
||||
#!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 \
|
||||
nsIImageManager.h \
|
||||
nsIImageGroup.h \
|
||||
nsIImageRequest.h \
|
||||
nsIImageObserver.h \
|
||||
nsIDeviceContext.h \
|
||||
nsIImage.h \
|
||||
nsIBlender.h \
|
||||
nsGfxCIID.h \
|
||||
nsIRegion.h \
|
||||
nsDeviceContext.h \
|
||||
nsIDeviceContextSpec.h \
|
||||
nsIDeviceContextSpecFactory.h \
|
||||
nsIDrawingSurface.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
102
mozilla/gfx/public/nsColor.h
Normal file
102
mozilla/gfx/public/nsColor.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsColor_h___
|
||||
#define nsColor_h___
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class nsString;
|
||||
|
||||
// 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 nsString& 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___ */
|
||||
196
mozilla/gfx/public/nsColorNameList.h
Normal file
196
mozilla/gfx/public/nsColorNameList.h
Normal file
@@ -0,0 +1,196 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/******
|
||||
|
||||
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))
|
||||
|
||||
62
mozilla/gfx/public/nsColorNames.h
Normal file
62
mozilla/gfx/public/nsColorNames.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsColorNames_h___
|
||||
#define nsColorNames_h___
|
||||
|
||||
#include "nsColor.h"
|
||||
|
||||
struct nsStr;
|
||||
class nsCString;
|
||||
|
||||
/*
|
||||
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 nsString& aName);
|
||||
static nsColorName LookupName(const nsCString& aName);
|
||||
|
||||
static const nsCString& GetStringValue(nsColorName aColorName);
|
||||
|
||||
// Color id to rgb value table
|
||||
static const nscolor kColors[];
|
||||
};
|
||||
|
||||
#endif /* nsColorNames_h___ */
|
||||
42
mozilla/gfx/public/nsCoord.h
Normal file
42
mozilla/gfx/public/nsCoord.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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 */
|
||||
125
mozilla/gfx/public/nsDeviceContext.h
Normal file
125
mozilla/gfx/public/nsDeviceContext.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsDeviceContext_h___
|
||||
#define nsDeviceContext_h___
|
||||
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "libimg.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class nsIImageRequest;
|
||||
class nsHashtable;
|
||||
class nsFontCache;
|
||||
|
||||
class DeviceContextImpl : public nsIDeviceContext
|
||||
{
|
||||
public:
|
||||
DeviceContextImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
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 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 LoadIconImage(PRInt32 aId, nsIImage*& aImage);
|
||||
|
||||
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
|
||||
|
||||
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
||||
PRBool& aAliased);
|
||||
|
||||
NS_IMETHOD FlushFontCache(void);
|
||||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
|
||||
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&);
|
||||
|
||||
protected:
|
||||
virtual ~DeviceContextImpl();
|
||||
|
||||
void CommonInit(void);
|
||||
nsresult CreateFontCache();
|
||||
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;
|
||||
IL_GroupContext* mIconImageGroup;
|
||||
nsIImageRequest* mIcons[NS_NUMBER_OF_ICONS];
|
||||
nsHashtable* mFontAliasTable;
|
||||
IL_ColorSpace* mColorSpace;
|
||||
float mCPixelScale;
|
||||
|
||||
public:
|
||||
nsNativeWidget mWidget;
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContext_h___ */
|
||||
101
mozilla/gfx/public/nsFont.h
Normal file
101
mozilla/gfx/public/nsFont.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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);
|
||||
|
||||
// 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 size of the font, in nscoord units
|
||||
nscoord size;
|
||||
|
||||
// Initialize the font struct with an iso-latin1 name
|
||||
nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize);
|
||||
|
||||
// Initialize the font struct with a (potentially) unicode name
|
||||
nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize);
|
||||
|
||||
// Make a copy of the given font
|
||||
nsFont(const nsFont& aFont);
|
||||
|
||||
~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, PF_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;
|
||||
};
|
||||
|
||||
#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___ */
|
||||
87
mozilla/gfx/public/nsGfxCIID.h
Normal file
87
mozilla/gfx/public/nsGfxCIID.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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_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 } }
|
||||
|
||||
|
||||
#endif
|
||||
84
mozilla/gfx/public/nsIBlender.h
Normal file
84
mozilla/gfx/public/nsIBlender.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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
|
||||
435
mozilla/gfx/public/nsIDeviceContext.h
Normal file
435
mozilla/gfx/public/nsIDeviceContext.h
Normal file
@@ -0,0 +1,435 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIDeviceContext_h___
|
||||
#define nsIDeviceContext_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
class nsIRenderingContext;
|
||||
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;
|
||||
|
||||
#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;
|
||||
PRUint8 sizePalette; // number of entries in the palette
|
||||
PRUint8 numReserved; // number of reserved palette entries
|
||||
nsPalette palette; // native palette handle
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
// Colors
|
||||
eSystemAttr_Color_WindowBackground,
|
||||
eSystemAttr_Color_WindowForeground,
|
||||
eSystemAttr_Color_WidgetBackground,
|
||||
eSystemAttr_Color_WidgetForeground,
|
||||
eSystemAttr_Color_WidgetSelectBackground,
|
||||
eSystemAttr_Color_WidgetSelectForeground,
|
||||
eSystemAttr_Color_Widget3DHighlight,
|
||||
eSystemAttr_Color_Widget3DShadow,
|
||||
eSystemAttr_Color_TextBackground,
|
||||
eSystemAttr_Color_TextForeground,
|
||||
eSystemAttr_Color_TextSelectBackground,
|
||||
eSystemAttr_Color_TextSelectForeground,
|
||||
// Size
|
||||
eSystemAttr_Size_WindowTitleHeight,
|
||||
eSystemAttr_Size_WindowBorderWidth,
|
||||
eSystemAttr_Size_WindowBorderHeight,
|
||||
eSystemAttr_Size_Widget3DBorder,
|
||||
eSystemAttr_Size_ScrollbarHeight,
|
||||
eSystemAttr_Size_ScrollbarWidth,
|
||||
// Fonts
|
||||
eSystemAttr_Font_Caption, // css2
|
||||
eSystemAttr_Font_Icon,
|
||||
eSystemAttr_Font_Menu,
|
||||
eSystemAttr_Font_MessageBox,
|
||||
eSystemAttr_Font_SmallCaption,
|
||||
eSystemAttr_Font_StatusBar,
|
||||
|
||||
eSystemAttr_Font_Window, // css3
|
||||
eSystemAttr_Font_Document,
|
||||
eSystemAttr_Font_Workspace,
|
||||
eSystemAttr_Font_Desktop,
|
||||
eSystemAttr_Font_Info,
|
||||
eSystemAttr_Font_Dialog,
|
||||
eSystemAttr_Font_Button,
|
||||
eSystemAttr_Font_PullDownMenu,
|
||||
eSystemAttr_Font_List,
|
||||
eSystemAttr_Font_Field,
|
||||
|
||||
eSystemAttr_Font_Tooltips, // moz
|
||||
eSystemAttr_Font_Widget
|
||||
} nsSystemAttrID;
|
||||
|
||||
typedef union {
|
||||
PRUint32 mSize;
|
||||
nscolor * mColor;
|
||||
nsFont * mFont;
|
||||
} SystemAttrStruct;
|
||||
|
||||
/**
|
||||
* Constants identifying pre-defined icons.
|
||||
* @see #LoadIcon()
|
||||
*/
|
||||
#define NS_ICON_LOADING_IMAGE 0
|
||||
#define NS_ICON_BROKEN_IMAGE 1
|
||||
#define NS_NUMBER_OF_ICONS 2
|
||||
|
||||
// XXX This is gross, but don't include libimg.h, because it includes ni_pixmap.h
|
||||
// which includes xp_core.h which includes windows.h
|
||||
struct _NI_ColorSpace;
|
||||
typedef _NI_ColorSpace NI_ColorSpace;
|
||||
typedef NI_ColorSpace IL_ColorSpace;
|
||||
|
||||
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 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;
|
||||
|
||||
/**
|
||||
* Get the width of a vertical scroll bar and the height
|
||||
* of a horizontal scrollbar in application units.
|
||||
* @param anID The snum of the type of information you want back
|
||||
* @param aInfo out parameter for the system data
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) 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;
|
||||
|
||||
//load the specified icon. this is a blocking call that does not return
|
||||
//until the icon is loaded.
|
||||
//release the image when you're done
|
||||
NS_IMETHOD LoadIconImage(PRInt32 aId, nsIImage*& aImage) = 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Return the image lib color space that's appropriate for this rendering
|
||||
* context.
|
||||
*
|
||||
* You must call IL_ReleaseSystemSpace() when you're done using the color space.
|
||||
*/
|
||||
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace) = 0;
|
||||
|
||||
/**
|
||||
* Returns information about the device's palette capabilities.
|
||||
*/
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&) = 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;
|
||||
};
|
||||
|
||||
#endif /* nsIDeviceContext_h___ */
|
||||
38
mozilla/gfx/public/nsIDeviceContextSpec.h
Normal file
38
mozilla/gfx/public/nsIDeviceContextSpec.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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
|
||||
69
mozilla/gfx/public/nsIDeviceContextSpecFactory.h
Normal file
69
mozilla/gfx/public/nsIDeviceContextSpecFactory.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIDeviceContextSpecFactory_h___
|
||||
#define nsIDeviceContextSpecFactory_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDeviceContextSpec;
|
||||
class nsIWidget;
|
||||
|
||||
#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,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
153
mozilla/gfx/public/nsIDrawingSurface.h
Normal file
153
mozilla/gfx/public/nsIDrawingSurface.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIDrawingSurface_h___
|
||||
#define nsIDrawingSurface_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsRect.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___
|
||||
217
mozilla/gfx/public/nsIFontMetrics.h
Normal file
217
mozilla/gfx/public/nsIFontMetrics.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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;
|
||||
|
||||
#if defined(MOZ_MATHML) && defined(WIN32)
|
||||
// XXX currently implemented only on win32 -- other platforms should implement this
|
||||
/**
|
||||
* Return the font's italic slope, i.e., the tangent of the italic angle.
|
||||
* The slope = 0 for an upright font. It is > 0 for a forward-slanted
|
||||
* font (italic style) and is < 0 for a back-slanted font.
|
||||
*/
|
||||
NS_IMETHOD GetItalicSlope(float& aResult) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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
|
||||
};
|
||||
|
||||
#endif /* nsIFontMetrics_h___ */
|
||||
290
mozilla/gfx/public/nsIImage.h
Normal file
290
mozilla/gfx/public/nsIImage.h
Normal file
@@ -0,0 +1,290 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIImage_h___
|
||||
#define nsIImage_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
//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. */
|
||||
} nsColorMap;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
145
mozilla/gfx/public/nsIImageGroup.h
Normal file
145
mozilla/gfx/public/nsIImageGroup.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIImageGroup_h___
|
||||
#define nsIImageGroup_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsColor.h"
|
||||
|
||||
class nsIImageGroupObserver;
|
||||
class nsIImageRequestObserver;
|
||||
class nsIImageRequest;
|
||||
class nsIDeviceContext;
|
||||
class nsIStreamListener;
|
||||
class nsILoadGroup;
|
||||
|
||||
/** For important images, like backdrops. */
|
||||
#define nsImageLoadFlags_kHighPriority 0x01
|
||||
/** Don't throw this image out of cache. */
|
||||
#define nsImageLoadFlags_kSticky 0x02
|
||||
/** Don't get image out of image cache. */
|
||||
#define nsImageLoadFlags_kBypassCache 0x04
|
||||
/** Don't load if image cache misses. */
|
||||
#define nsImageLoadFlags_kOnlyFromCache 0x08
|
||||
|
||||
|
||||
// IID for the nsIImageGroup interface
|
||||
#define NS_IIMAGEGROUP_IID \
|
||||
{ 0xbe927e40, 0xaeaa, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
*
|
||||
* Image group. A convenient way to group a set of image load requests
|
||||
* and control them as a group.
|
||||
*/
|
||||
class nsIImageGroup : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEGROUP_IID)
|
||||
|
||||
/**
|
||||
* Initialize an image group with a device context. All images
|
||||
* in this group will be decoded for the specified device context.
|
||||
*/
|
||||
virtual nsresult Init(nsIDeviceContext *aDeviceContext, nsISupports *aLoadContext) = 0;
|
||||
|
||||
/**
|
||||
* Add an observers to be informed of image group notifications.
|
||||
*
|
||||
* @param aObserver - An observer to add to the observer list.
|
||||
* @param boolean indicating whether addition was successful.
|
||||
*/
|
||||
virtual PRBool AddObserver(nsIImageGroupObserver *aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove a previously added observer from the observer list.
|
||||
*
|
||||
* @param aObserver - An observer to remove from the observer list.
|
||||
* @param boolean indicating whether the removal was successful.
|
||||
*/
|
||||
virtual PRBool RemoveObserver(nsIImageGroupObserver *aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Fetch the image corresponding to the specified URL.
|
||||
*
|
||||
* @param aUrl - the URL of the image to be loaded.
|
||||
* @param aObserver - the observer is notified at significant
|
||||
* points in image loading.
|
||||
* @param aWidth, aHeight - These parameters specify the target
|
||||
* dimensions of the image. The image will be stretched
|
||||
* horizontally, vertically or both to meet these parameters.
|
||||
* If both width and height are zero, the image is decoded
|
||||
* using its "natural" size. If only one of width and height
|
||||
* is zero, the image is scaled to the provided dimension, with
|
||||
* the unspecified dimension scaled to maintain the image's
|
||||
* original aspect ratio.
|
||||
* @param aBackgroundColor - If the background color is NULL, a mask
|
||||
* will be generated for any transparent images. If background
|
||||
* color is non-NULL, it indicates the RGB value to be painted
|
||||
* into the image for "transparent" areas of the image, in which
|
||||
* case no mask is created. This is intended for backdrops and
|
||||
* printing.
|
||||
* @param aFlags - image loading flags are specified above
|
||||
*
|
||||
* @return the resulting image request object.
|
||||
*/
|
||||
virtual nsIImageRequest* GetImage(const char* aUrl,
|
||||
nsIImageRequestObserver *aObserver,
|
||||
const nscolor* aBackgroundColor,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
PRUint32 aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Like GetImage except load the image from a live stream.
|
||||
* The call returns an nsIImageRequest and an nsIStreamListener
|
||||
* that should be connected to the live stream to accept
|
||||
* the image data.
|
||||
*/
|
||||
NS_IMETHOD GetImageFromStream(const char* aURL,
|
||||
nsIImageRequestObserver *aObserver,
|
||||
const nscolor* aBackgroundColor,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
PRUint32 aFlags,
|
||||
nsIImageRequest*& aResult,
|
||||
nsIStreamListener*& aListenerResult) = 0;
|
||||
|
||||
/**
|
||||
* Halt decoding of images or animation without destroying associated
|
||||
* pixmap data. All ImageRequests created with this ImageGroup
|
||||
* are interrupted.
|
||||
*/
|
||||
virtual void Interrupt(void) = 0;
|
||||
|
||||
NS_IMETHOD SetImgLoadAttributes(PRUint32 a_grouploading_attribs)=0;
|
||||
NS_IMETHOD GetImgLoadAttributes(PRUint32 *a_grouploading_attribs)=0;
|
||||
|
||||
};
|
||||
|
||||
/// Factory method for creating an image group
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageGroup(nsIImageGroup **aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
99
mozilla/gfx/public/nsIImageManager.h
Normal file
99
mozilla/gfx/public/nsIImageManager.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIImageManager_h___
|
||||
#define nsIImageManager_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
nsImageType_kUnknown = 0,
|
||||
nsImageType_kGIF = 1,
|
||||
nsImageType_kXBM = 2,
|
||||
nsImageType_kJPEG = 3,
|
||||
nsImageType_kPPM = 4,
|
||||
nsImageType_kPNG = 5,
|
||||
nsImageType_kART = 6
|
||||
} nsImageType;
|
||||
|
||||
// IID for the nsIImageManager interface
|
||||
#define NS_IIMAGEMANAGER_IID \
|
||||
{ 0x9f327100, 0xad5a, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
*
|
||||
* Image manager. There is only a single instance, returned when invoking
|
||||
* the factory instantiation method. A user of the image library should
|
||||
* hold on to the singleton image manager.
|
||||
*/
|
||||
class nsIImageManager : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEMANAGER_IID)
|
||||
|
||||
/// Initialization method to be called before use
|
||||
virtual nsresult Init() = 0;
|
||||
|
||||
/// Set the size (in bytes) image cache maintained by the image manager
|
||||
virtual void SetCacheSize(PRInt32 aCacheSize) = 0;
|
||||
|
||||
/// @return the current size of the image cache (in bytes)
|
||||
virtual PRInt32 GetCacheSize(void) = 0;
|
||||
|
||||
/**
|
||||
* Attempts to release some memory by freeing an image from the image
|
||||
* cache. This may not always be possible either because all images
|
||||
* in the cache are in use or because the cache is empty.
|
||||
*
|
||||
* @return the new approximate size of the imagelib cache.
|
||||
*/
|
||||
virtual PRInt32 ShrinkCache(void) = 0;
|
||||
|
||||
/**
|
||||
* Flush the image cache as much as possible. The only images not
|
||||
* flushed out will be those that are in use.
|
||||
*/
|
||||
NS_IMETHOD FlushCache(PRUint8 img_catagory) = 0;
|
||||
|
||||
/**
|
||||
* Determine the type of the image, based on the first few bytes of data.
|
||||
*
|
||||
* @param buf - a buffer of image data
|
||||
* @param length - the length of the buffer
|
||||
*
|
||||
* @return the type of the image, if known
|
||||
*/
|
||||
// virtual nsImageType GetImageType(const char *buf, PRInt32 length) = 0;
|
||||
};
|
||||
|
||||
/// Factory method to get a reference to the singleton image manager
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageManager(nsIImageManager **aInstancePtrResult);
|
||||
|
||||
extern "C" NS_GFX_(void)
|
||||
NS_FreeImageManager();
|
||||
|
||||
#endif
|
||||
175
mozilla/gfx/public/nsIImageObserver.h
Normal file
175
mozilla/gfx/public/nsIImageObserver.h
Normal file
@@ -0,0 +1,175 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIImageObserver_h___
|
||||
#define nsIImageObserver_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIImage;
|
||||
class nsIImageRequest;
|
||||
class nsIImageGroup;
|
||||
|
||||
/// Image request notifications
|
||||
typedef enum {
|
||||
nsImageNotification_kStartURL, // Start of decode/display for URL.
|
||||
nsImageNotification_kDescription, // Availability of image description.
|
||||
nsImageNotification_kDimensions, // Availability of image dimensions.
|
||||
nsImageNotification_kIsTransparent, // This image is transparent.
|
||||
nsImageNotification_kPixmapUpdate, // Change in a rectangular area of
|
||||
// pixels.
|
||||
nsImageNotification_kFrameComplete, // Completion of a frame of an animated
|
||||
// image.
|
||||
nsImageNotification_kProgress, // Notification of percentage decoded.
|
||||
nsImageNotification_kImageComplete, // Completion of image decoding. There
|
||||
// may be multiple instances of this
|
||||
// event per URL due to server push,
|
||||
// client pull or looping GIF animation.
|
||||
nsImageNotification_kStopURL, // Completion of decode/display for URL.
|
||||
nsImageNotification_kImageDestroyed,// Finalization of an image request. This
|
||||
// is an indication to perform any
|
||||
// observer related cleanup.
|
||||
nsImageNotification_kAborted, // Image decode was aborted by either
|
||||
// the network library or Interrupt().
|
||||
nsImageNotification_kInternalImage // Internal image icon.
|
||||
} nsImageNotification;
|
||||
|
||||
/// Image group notifications
|
||||
typedef enum {
|
||||
|
||||
// Start of image loading. Sent when a loading image is
|
||||
// added to an image group which currently has no loading images.
|
||||
nsImageGroupNotification_kStartedLoading,
|
||||
|
||||
// Some images were aborted. A finished loading message will not be sent
|
||||
// until the aborted images have been destroyed.
|
||||
nsImageGroupNotification_kAbortedLoading,
|
||||
|
||||
// End of image loading. Sent when the last of the images currently
|
||||
// in the image group has finished loading.
|
||||
nsImageGroupNotification_kFinishedLoading,
|
||||
|
||||
// Start of image looping. Sent when an animated image starts looping in
|
||||
// an image group which currently has no looping animations.
|
||||
nsImageGroupNotification_kStartedLooping,
|
||||
|
||||
// End of image looping. Sent when the last of the images currently in
|
||||
// the image group has finished looping.
|
||||
nsImageGroupNotification_kFinishedLooping
|
||||
|
||||
} nsImageGroupNotification;
|
||||
|
||||
/// Image loading errors
|
||||
typedef enum {
|
||||
nsImageError_kNotInCache, // Image URL not available in cache when
|
||||
// kOnlyFromCache flag was set.
|
||||
nsImageError_kNoData, // Network library unable to fetch
|
||||
// provided URL.
|
||||
nsImageError_kImageDataCorrupt, // Checksum error of some kind in
|
||||
// image data.
|
||||
nsImageError_kImageDataTruncated, // Missing data at end of stream.
|
||||
nsImageError_kImageDataIllegal, // Generic image data error.
|
||||
nsImageError_kInternalError // Internal Image Library error.
|
||||
|
||||
} nsImageError;
|
||||
|
||||
// IID for the nsIImageRequestObserver interface
|
||||
#define NS_IIMAGEREQUESTOBSERVER_IID \
|
||||
{ 0x965467a0, 0xb8f4, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
// IID for the nsIImageGroupObserver interface
|
||||
#define NS_IIMAGEGROUPOBSERVER_IID \
|
||||
{ 0xb3cad300, 0xb8f4, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
* Image request observer interface. The implementor will be notified
|
||||
* of significant loading events or loading errors.
|
||||
*/
|
||||
class nsIImageRequestObserver : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEREQUESTOBSERVER_IID)
|
||||
|
||||
/**
|
||||
* Notify the observer of some significant image event. The parameter
|
||||
* values depend on the notification type as specified below.
|
||||
*
|
||||
* kDescription - aParam3 is a string containing the human readable
|
||||
* description of an image, e.g. "GIF89a 320 x 240 pixels".
|
||||
* The string storage is static, so it must be copied if
|
||||
* it is to be preserved after the call to the observer.
|
||||
* kDimensions - aParam1 and aParam2 are the width and height respectively
|
||||
* of the image in pixels.
|
||||
* kPixmapUpdate - aParame3 is a pointer to a nsRect struct containing the
|
||||
* rectangular area of pixels which has been modified by
|
||||
* the image library. This notification enables the
|
||||
* client to drive the progressive display of the image.
|
||||
* kProgress - aParam1 represents the estimated percentage decoded. This
|
||||
* notification occurs at unspecified intervals. Provided
|
||||
* that decoding proceeds without error, it is guaranteed that
|
||||
* notification will take place on completion with a
|
||||
* percent_progress value of 100.
|
||||
*
|
||||
* @param aImageRequest - the image request in question
|
||||
* @param aImage - the corresponding image object
|
||||
* @param aNotificationType - the type of notification
|
||||
* @param aParam1, aParam2, aParam3 - additional information as described
|
||||
* above.
|
||||
*/
|
||||
virtual void Notify(nsIImageRequest *aImageRequest,
|
||||
nsIImage *aImage,
|
||||
nsImageNotification aNotificationType,
|
||||
PRInt32 aParam1, PRInt32 aParam2,
|
||||
void *aParam3)=0;
|
||||
|
||||
/**
|
||||
* Notify the observer of an error during image loading.
|
||||
*
|
||||
* @param aImageRequest - the image request in question
|
||||
* @param aErrorType - the error code
|
||||
*/
|
||||
virtual void NotifyError(nsIImageRequest *aImageRequest,
|
||||
nsImageError aErrorType)=0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Image group observer interface. The implementor will be notified
|
||||
* of significant image group events.
|
||||
*/
|
||||
class nsIImageGroupObserver : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEGROUPOBSERVER_IID)
|
||||
|
||||
/**
|
||||
* Notify the observer of some significant image group event.
|
||||
*
|
||||
* @param aImageGroup - the image group in question
|
||||
* @param aNotificationType - the notification code
|
||||
*/
|
||||
virtual void Notify(nsIImageGroup *aImageGroup,
|
||||
nsImageGroupNotification aNotificationType)=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
81
mozilla/gfx/public/nsIImageRequest.h
Normal file
81
mozilla/gfx/public/nsIImageRequest.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIImageRequest_h___
|
||||
#define nsIImageRequest_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIImageRequestObserver;
|
||||
class nsIImage;
|
||||
|
||||
// IID for the nsIImageRequest interface
|
||||
#define NS_IIMAGEREQUEST_IID \
|
||||
{ 0xc31444c0, 0xaec9, 0x11d1, \
|
||||
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
|
||||
|
||||
/**
|
||||
*
|
||||
* An image request generated as a result of invoking the
|
||||
* <code>GetImage</code> method of the <code>nsIImageGroup</code>
|
||||
* interface.
|
||||
*/
|
||||
class nsIImageRequest : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEREQUEST_IID)
|
||||
|
||||
/// @return the image object associated with the request.
|
||||
virtual nsIImage* GetImage() = 0;
|
||||
|
||||
/**
|
||||
* Returns the natural dimensions of the image. Returns 0,0
|
||||
* if the dimensions are unknown.
|
||||
*
|
||||
* Note: the dimensions that are returned are in pixels
|
||||
*
|
||||
* @param aWidth, aHeight - pointers to integers to be filled in with
|
||||
* the dimensions.
|
||||
*/
|
||||
virtual void GetNaturalDimensions(PRUint32 *aWidth, PRUint32 *aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Add an observers to be informed of image loading notifications.
|
||||
*
|
||||
* @param aObserver - An observer to add to the observer list.
|
||||
* @param boolean indicating whether addition was successful.
|
||||
*/
|
||||
virtual PRBool AddObserver(nsIImageRequestObserver *aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove a previously added observer from the observer list.
|
||||
*
|
||||
* @param aObserver - An observer to remove from the observer list.
|
||||
* @param boolean indicating whether the removal was successful.
|
||||
*/
|
||||
virtual PRBool RemoveObserver(nsIImageRequestObserver *aObserver) = 0;
|
||||
|
||||
/// Interrupt loading of just this image.
|
||||
virtual void Interrupt() = 0;
|
||||
};
|
||||
#endif
|
||||
76
mozilla/gfx/public/nsIPrintingContext.h
Normal file
76
mozilla/gfx/public/nsIPrintingContext.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- 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):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsIPrintingContextMac_h___
|
||||
#define nsIPrintingContextMac_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// 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(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___ */
|
||||
263
mozilla/gfx/public/nsIRegion.h
Normal file
263
mozilla/gfx/public/nsIRegion.h
Normal file
@@ -0,0 +1,263 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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___
|
||||
939
mozilla/gfx/public/nsIRenderingContext.h
Normal file
939
mozilla/gfx/public/nsIRenderingContext.h
Normal file
@@ -0,0 +1,939 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsIRenderingContext_h___
|
||||
#define nsIRenderingContext_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsIDrawingSurface.h"
|
||||
|
||||
class nsIWidget;
|
||||
class nsIFontMetrics;
|
||||
class nsIImage;
|
||||
class nsTransform2D;
|
||||
class nsString;
|
||||
class nsIDeviceContext;
|
||||
class nsIRegion;
|
||||
|
||||
struct nsFont;
|
||||
struct nsPoint;
|
||||
struct nsRect;
|
||||
#ifdef MOZ_MATHML
|
||||
struct nsBoundingMetrics;
|
||||
#endif
|
||||
|
||||
|
||||
/* gfx2 */
|
||||
#include "gfxtypes.h"
|
||||
class gfxIImageContainer;
|
||||
|
||||
|
||||
//cliprect/region combination methods
|
||||
|
||||
typedef enum
|
||||
{
|
||||
nsClipCombine_kIntersect = 0,
|
||||
nsClipCombine_kUnion = 1,
|
||||
nsClipCombine_kSubtract = 2,
|
||||
nsClipCombine_kReplace = 3
|
||||
} nsClipCombine;
|
||||
|
||||
//linestyles
|
||||
typedef enum
|
||||
{
|
||||
nsLineStyle_kNone = 0,
|
||||
nsLineStyle_kSolid = 1,
|
||||
nsLineStyle_kDashed = 2,
|
||||
nsLineStyle_kDotted = 3
|
||||
} nsLineStyle;
|
||||
|
||||
// IID for the nsIRenderingContext interface
|
||||
#define NS_IRENDERING_CONTEXT_IID \
|
||||
{ 0xa6cf9068, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
//a cross platform way of specifying a native rendering context
|
||||
typedef void * nsDrawingSurface;
|
||||
|
||||
// RenderingContext interface
|
||||
class nsIRenderingContext : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRENDERING_CONTEXT_IID)
|
||||
|
||||
//TBD: bind/unbind, transformation of scalars (hacky),
|
||||
//potential drawmode for selection, polygons. MMP
|
||||
|
||||
/**
|
||||
* Initialize the RenderingContext
|
||||
* @param aContext the device context to use.
|
||||
* @param aWidget the widget to hook up to
|
||||
* @result The result of the initialization, NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWidget) = 0;
|
||||
|
||||
/**
|
||||
* Initialize the RenderingContext
|
||||
* @param aContext the device context to use for the drawing.
|
||||
* @param aSurface the surface to draw into
|
||||
* @result The result of the initialization, NS_Ok if no errors
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface) = 0;
|
||||
|
||||
/**
|
||||
* Reset the rendering context
|
||||
*/
|
||||
NS_IMETHOD Reset(void) = 0;
|
||||
|
||||
/**
|
||||
* Get the DeviceContext that this RenderingContext was initialized with
|
||||
* @result the device context
|
||||
*/
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *& aDeviceContext) = 0;
|
||||
|
||||
/**
|
||||
* Lock a rect of the drawing surface associated with the
|
||||
* rendering context. do not attempt to use any of the Rendering Context
|
||||
* rendering or state management methods until the drawing surface has
|
||||
* been Unlock()ed. if a drawing surface is Lock()ed with this method,
|
||||
* it must be Unlock()ed by calling UnlockDrawingSurface() rather than
|
||||
* just calling the Unlock() method on the drawing surface directly.
|
||||
* see nsIDrawingSurface.h for more information
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Unlock a rect of the drawing surface associated with the rendering
|
||||
* context. see nsIDrawingSurface.h for more information.
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD UnlockDrawingSurface(void) = 0;
|
||||
|
||||
/**
|
||||
* Selects an offscreen drawing surface into the RenderingContext to draw to.
|
||||
* @param aSurface is the offscreen surface we are going to draw to.
|
||||
* if nsnull, the original drawing surface obtained at initialization
|
||||
* should be selected.
|
||||
*/
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface) = 0;
|
||||
|
||||
/**
|
||||
* Get the currently selected drawing surface
|
||||
* @param aSurface out parameter for the current drawing surface
|
||||
*/
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface) = 0;
|
||||
|
||||
/**
|
||||
* Returns in aResult any rendering hints that the context has.
|
||||
* See below for the hints bits. Always returns NS_OK.
|
||||
*/
|
||||
NS_IMETHOD GetHints(PRUint32& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Save a graphical state onto a stack.
|
||||
*/
|
||||
NS_IMETHOD PushState(void) = 0;
|
||||
|
||||
/**
|
||||
* Get and and set RenderingContext to this graphical state
|
||||
* @return if PR_TRUE, indicates that the clipping region after
|
||||
* popping state is empty, else PR_FALSE
|
||||
*/
|
||||
NS_IMETHOD PopState(PRBool &aClipEmpty) = 0;
|
||||
|
||||
/**
|
||||
* Tells if a given rectangle is visible within the rendering context
|
||||
* @param aRect is the rectangle that will be checked for visiblity
|
||||
* @result If true, that rectanglular area is visable.
|
||||
*/
|
||||
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aIsVisible) = 0;
|
||||
|
||||
/**
|
||||
* Sets the clipping for the RenderingContext to the passed in rectangle
|
||||
* @param aRect The rectangle to set the clipping rectangle to
|
||||
* @param aCombine how to combine this rect with the current clip region.
|
||||
* see the bottom of nsIRenderingContext.h
|
||||
* @return PR_TRUE if the clip region is now empty, else PR_FALSE
|
||||
*/
|
||||
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty) = 0;
|
||||
|
||||
/**
|
||||
* Gets the bounds of the clip region of the RenderingContext
|
||||
* @param aRect out parameter to contain the clip region bounds
|
||||
* for the RenderingContext
|
||||
* @return PR_TRUE if the rendering context has a local cliprect set
|
||||
* else aRect is undefined
|
||||
*/
|
||||
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aHasLocalClip) = 0;
|
||||
|
||||
/**
|
||||
* Sets the line style for the RenderingContext
|
||||
* @param aLineStyle The line style
|
||||
* @return NS_OK if the line style is correctly set
|
||||
*/
|
||||
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle) = 0;
|
||||
|
||||
/**
|
||||
* Gets the line style for the RenderingContext
|
||||
* @param aLineStyle The line style to be retrieved
|
||||
* @return NS_OK if the line style is correctly retrieved
|
||||
*/
|
||||
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle) = 0;
|
||||
|
||||
/**
|
||||
* Sets the clipping for the RenderingContext to the passed in region
|
||||
* @param aRegion The region to set the clipping area to
|
||||
* @param aCombine how to combine this region with the current clip region.
|
||||
* see the bottom of nsIRenderingContext.h
|
||||
* @return PR_TRUE if the clip region is now empty, else PR_FALSE
|
||||
*/
|
||||
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty) = 0;
|
||||
|
||||
/**
|
||||
* Gets a copy of the current clipping region for the RenderingContext
|
||||
* @param aRegion inout parameter representing the clip region.
|
||||
* if SetClipRegion() is called, do not assume that GetClipRegion()
|
||||
* will return the same object.
|
||||
*/
|
||||
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion) = 0;
|
||||
|
||||
/**
|
||||
* Gets the current clipping region for the RenderingContext
|
||||
* @param aRegion out parameter representing the clip region.
|
||||
* if SetClipRegion() is called, do not assume that GetClipRegion()
|
||||
* will return the same object.
|
||||
*/
|
||||
NS_IMETHOD GetClipRegion(nsIRegion **aRegion) = 0;
|
||||
|
||||
/**
|
||||
* Sets the forground color for the RenderingContext
|
||||
* @param aColor The color to set the RenderingContext to
|
||||
*/
|
||||
NS_IMETHOD SetColor(nscolor aColor) = 0;
|
||||
|
||||
/**
|
||||
* Get the forground color for the RenderingContext
|
||||
* @return The current forground color of the RenderingContext
|
||||
*/
|
||||
NS_IMETHOD GetColor(nscolor &aColor) const = 0;
|
||||
|
||||
/**
|
||||
* Sets the font for the RenderingContext
|
||||
* @param aFont The font to use in the RenderingContext
|
||||
*/
|
||||
NS_IMETHOD SetFont(const nsFont& aFont) = 0;
|
||||
|
||||
/**
|
||||
* Sets the font for the RenderingContext
|
||||
* @param aFontMetric The font metrics representing the
|
||||
* font to use in the RenderingContext
|
||||
*/
|
||||
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics) = 0;
|
||||
|
||||
/**
|
||||
* Get the current fontmetrics for the RenderingContext
|
||||
* @return The current font of the RenderingContext
|
||||
*/
|
||||
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics) = 0;
|
||||
|
||||
/**
|
||||
* Add in a translate to the RenderingContext's transformation matrix
|
||||
* @param aX The horizontal translation
|
||||
* @param aY The vertical translation
|
||||
*/
|
||||
NS_IMETHOD Translate(nscoord aX, nscoord aY) = 0;
|
||||
|
||||
/**
|
||||
* Add in a scale to the RenderingContext's transformation matrix
|
||||
* @param aX The horizontal scale
|
||||
* @param aY The vertical scale
|
||||
*/
|
||||
NS_IMETHOD Scale(float aSx, float aSy) = 0;
|
||||
|
||||
/**
|
||||
* Get the current transformation matrix for the RenderingContext
|
||||
* @return The transformation matrix for the RenderingContext
|
||||
*/
|
||||
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform) = 0;
|
||||
|
||||
/**
|
||||
* Create an offscreen drawing surface compatible with this RenderingContext.
|
||||
* The rect passed in is not affected by any transforms in the rendering
|
||||
* context and the values are in device units.
|
||||
* @param aBounds A rectangle representing the size for the drawing surface.
|
||||
* if nsnull then a bitmap will not be created and associated
|
||||
* with the new drawing surface
|
||||
* @param aSurfFlags see bottom of nsIRenderingContext.h
|
||||
* @return A nsDrawingSurface
|
||||
*/
|
||||
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface) = 0;
|
||||
|
||||
/**
|
||||
* Destroy a drawing surface created by CreateDrawingSurface()
|
||||
* @param aDS A drawing surface to destroy
|
||||
*/
|
||||
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS) = 0;
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
* @param aXO starting horiztonal coord in twips
|
||||
* @param aY0 starting vertical coord in twips
|
||||
* @param aX1 end horiztonal coord in twips
|
||||
* @param aY1 end vertical coord in twips
|
||||
*/
|
||||
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Draw a line without being transformed
|
||||
* @param aXO starting horiztonal coord in twips
|
||||
* @param aY0 starting vertical coord in twips
|
||||
* @param aX1 end horiztonal coord in twips
|
||||
* @param aY1 end vertical coord in twips
|
||||
*/
|
||||
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) = 0;
|
||||
|
||||
/**
|
||||
* Draw a polyline
|
||||
* @param aPoints array of endpoints
|
||||
* @param aNumPonts number of points
|
||||
*/
|
||||
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
|
||||
|
||||
/**
|
||||
* Draw a rectangle
|
||||
* @param aRect The rectangle to draw
|
||||
*/
|
||||
NS_IMETHOD DrawRect(const nsRect& aRect) = 0;
|
||||
|
||||
/**
|
||||
* Draw a rectangle
|
||||
* @param aX Horizontal left Coordinate in twips
|
||||
* @param aY Vertical top Coordinate in twips
|
||||
* @param aWidth Width of rectangle in twips
|
||||
* @param aHeight Height of rectangle in twips
|
||||
*/
|
||||
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Fill a rectangle in the current foreground color
|
||||
* @param aRect The rectangle to draw
|
||||
*/
|
||||
NS_IMETHOD FillRect(const nsRect& aRect) = 0;
|
||||
|
||||
/**
|
||||
* Fill a rectangle in the current foreground color
|
||||
* @param aX Horizontal left Coordinate in twips
|
||||
* @param aY Vertical top Coordinate in twips
|
||||
* @param aWidth Width of rectangle in twips
|
||||
* @param aHeight Height of rectangle in twips
|
||||
*/
|
||||
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* XOR Invert a rectangle in the current foreground color
|
||||
* @param aRect The rectangle to draw
|
||||
*/
|
||||
NS_IMETHOD InvertRect(const nsRect& aRect) = 0;
|
||||
|
||||
/**
|
||||
* XOR Invert a rectangle in the current foreground color
|
||||
* @param aX Horizontal left Coordinate in twips
|
||||
* @param aY Vertical top Coordinate in twips
|
||||
* @param aWidth Width of rectangle in twips
|
||||
* @param aHeight Height of rectangle in twips
|
||||
*/
|
||||
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Draw 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 DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
|
||||
|
||||
/**
|
||||
* 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 FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
|
||||
|
||||
/**
|
||||
* Rasterize a polygon with the current fill 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)=0;
|
||||
|
||||
/**
|
||||
* Fill a poly in the current foreground color, without transformation taking place
|
||||
* @param aPoints points to use for the drawing, last must equal first
|
||||
* @param aNumPonts number of points in the polygon
|
||||
*/
|
||||
NS_IMETHOD FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
|
||||
|
||||
/**
|
||||
* Draw an ellipse in the current foreground color
|
||||
* @param aRect The rectangle define bounds of ellipse to draw
|
||||
*/
|
||||
NS_IMETHOD DrawEllipse(const nsRect& aRect) = 0;
|
||||
|
||||
/**
|
||||
* Draw an ellipse in the current foreground color
|
||||
* @param aX Horizontal left Coordinate in twips
|
||||
* @param aY Vertical top Coordinate in twips
|
||||
* @param aWidth Width of horizontal axis in twips
|
||||
* @param aHeight Height of vertical axis in twips
|
||||
*/
|
||||
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Fill an ellipse in the current foreground color
|
||||
* @param aRect The rectangle define bounds of ellipse to draw
|
||||
*/
|
||||
NS_IMETHOD FillEllipse(const nsRect& aRect) = 0;
|
||||
|
||||
/**
|
||||
* Fill an ellipse in the current foreground color
|
||||
* @param aX Horizontal left Coordinate in twips
|
||||
* @param aY Vertical top Coordinate in twips
|
||||
* @param aWidth Width of horizontal axis in twips
|
||||
* @param aHeight Height of vertical axis in twips
|
||||
*/
|
||||
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Draw an arc in the current forground color
|
||||
* @param aRect The rectangle define bounds of ellipse to use
|
||||
* @param aStartAngle the starting angle of the arc, in the ellipse
|
||||
* @param aEndAngle The ending angle of the arc, in the ellipse
|
||||
*/
|
||||
NS_IMETHOD DrawArc(const nsRect& aRect,
|
||||
float aStartAngle, float aEndAngle) = 0;
|
||||
|
||||
/**
|
||||
* Draw an arc in the current forground color
|
||||
* @param aX Horizontal left Coordinate in twips
|
||||
* @param aY Vertical top Coordinate in twips
|
||||
* @param aWidth Width of horizontal axis in twips
|
||||
* @param aHeight Height of vertical axis in twips
|
||||
* @param aStartAngle the starting angle of the arc, in the ellipse
|
||||
* @param aEndAngle The ending angle of the arc, in the ellipse
|
||||
*/
|
||||
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
float aStartAngle, float aEndAngle) = 0;
|
||||
|
||||
/**
|
||||
* Fill an arc in the current forground color
|
||||
* @param aRect The rectangle define bounds of ellipse to use
|
||||
* @param aStartAngle the starting angle of the arc, in the ellipse
|
||||
* @param aEndAngle The ending angle of the arc, in the ellipse
|
||||
*/
|
||||
NS_IMETHOD FillArc(const nsRect& aRect,
|
||||
float aStartAngle, float aEndAngle) = 0;
|
||||
|
||||
/**
|
||||
* Fill an arc in the current forground color
|
||||
* @param aX Horizontal left Coordinate in twips
|
||||
* @param aY Vertical top Coordinate in twips
|
||||
* @param aWidth Width of horizontal axis in twips
|
||||
* @param aHeight Height of vertical axis in twips
|
||||
* @param aStartAngle the starting angle of the arc, in the ellipse
|
||||
* @param aEndAngle The ending angle of the arc, in the ellipse
|
||||
*/
|
||||
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
float aStartAngle, float aEndAngle) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aC character to measure
|
||||
* @param aWidth out parameter for width
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of a unicode character
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aC character to measure
|
||||
* @param aWidth out parameter for width
|
||||
* @param aFontID an optional out parameter used to store a
|
||||
* font identifier that can be passed into the DrawString()
|
||||
* methods to speed rendering
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
|
||||
PRInt32 *aFontID = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an nsString
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aString string to measure
|
||||
* @param aWidth out parameter for width
|
||||
* @param aFontID an optional out parameter used to store a
|
||||
* font identifier that can be passed into the DrawString()
|
||||
* methods to speed rendering
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
|
||||
PRInt32 *aFontID = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character string
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aString string to measure
|
||||
* @param aWidth out parameter for width
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of an 8-bit character string
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aString string to measure
|
||||
* @param aLength number of characters in string
|
||||
* @param aWidth out parameter for width
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
|
||||
nscoord& aWidth) = 0;
|
||||
|
||||
/**
|
||||
* Returns the width (in app units) of a Unicode character string
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aString string to measure
|
||||
* @param aLength number of characters in string
|
||||
* @param aWidth out parameter for width
|
||||
* @param aFontID an optional out parameter used to store a
|
||||
* font identifier that can be passed into the DrawString()
|
||||
* methods to speed rendering
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
|
||||
nscoord &aWidth, PRInt32 *aFontID = nsnull) = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
/**
|
||||
* Given an available width and an array of break points,
|
||||
* returns the width (in app units) of the text that fit and
|
||||
* the number of characters that fit. The number of characters
|
||||
* corresponds to an entry in the break array.
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aString 8-bit character string to measure
|
||||
* @param aLength number of characters in string
|
||||
* @param aAvailWidth the available space in which the text must fit
|
||||
* @param aBreaks array of places to break. Specified as offsets from the
|
||||
* start of the string
|
||||
* @param aNumBreaks the number of entries in the break array. The last
|
||||
* entry in the break array must equal the length of the string
|
||||
* @param aWidth out parameter for width
|
||||
* @param aNumCharsFit the number of characters that fit in the available space
|
||||
* @param aFontID an optional out parameter used to store a
|
||||
* font identifier that can be passed into the DrawString()
|
||||
* methods to speed rendering
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const char *aString,
|
||||
PRInt32 aLength,
|
||||
PRInt32 aAvailWidth,
|
||||
PRInt32* aBreaks,
|
||||
PRInt32 aNumBreaks,
|
||||
nscoord& aWidth,
|
||||
PRInt32& aNumCharsFit,
|
||||
PRInt32* aFontID = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Given an available width and an array of break points,
|
||||
* returns the width (in app units) of the text that fit and
|
||||
* the number of characters that fit. The number of characters
|
||||
* corresponds to an entry in the break array.
|
||||
* If no font has been Set, the results are undefined.
|
||||
* @param aString Unicode string to measure
|
||||
* @param aLength number of characters in string
|
||||
* @param aAvailWidth the available space in which the text must fit
|
||||
* @param aBreaks array of places to break. Specified as offsets from the
|
||||
* start of the string
|
||||
* @param aNumBreaks the number of entries in the break array. The last
|
||||
* entry in the break array must equal the length of the string
|
||||
* @param aWidth out parameter for width
|
||||
* @param aNumCharsFit the number of characters that fit in the available space
|
||||
* @param aFontID an optional out parameter used to store a
|
||||
* font identifier that can be passed into the DrawString()
|
||||
* methods to speed rendering
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetWidth(const PRUnichar *aString,
|
||||
PRInt32 aLength,
|
||||
PRInt32 aAvailWidth,
|
||||
PRInt32* aBreaks,
|
||||
PRInt32 aNumBreaks,
|
||||
nscoord& aWidth,
|
||||
PRInt32& aNumCharsFit,
|
||||
PRInt32* aFontID = nsnull) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Draw a string in the RenderingContext
|
||||
* @param aString The string to draw
|
||||
* @param aLength The length of the aString
|
||||
* @param aX Horizontal starting point of baseline
|
||||
* @param aY Vertical starting point of baseline.
|
||||
* @param aSpacing inter-character spacing to apply
|
||||
*/
|
||||
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
const nscoord* aSpacing = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Draw a string in the RenderingContext
|
||||
* @param aString A PRUnichar of the string
|
||||
* @param aLength The length of the aString
|
||||
* @param aX Horizontal starting point of baseline
|
||||
* @param aY Vertical starting point of baseline.
|
||||
* @param aFontID an optional parameter used to speed font
|
||||
* selection for complex unicode strings. the value
|
||||
* passed is returned by the DrawString() methods.
|
||||
* @param aSpacing inter-character spacing to apply
|
||||
*/
|
||||
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
|
||||
nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID = -1,
|
||||
const nscoord* aSpacing = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Draw a string in the RenderingContext
|
||||
* @param aString A nsString of the string
|
||||
* @param aX Horizontal starting point of baseline
|
||||
* @param aY Vertical starting point of baseline.
|
||||
* @param aFontID an optional parameter used to speed font
|
||||
* selection for complex unicode strings. the value
|
||||
* passed is returned by the DrawString() methods.
|
||||
* @param aSpacing inter-character spacing to apply
|
||||
*/
|
||||
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID = -1,
|
||||
const nscoord* aSpacing = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext
|
||||
* @param aX Horzontal left destination coordinate
|
||||
* @param aY Vertical top of destinatio coordinate
|
||||
*/
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) = 0;
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext, scaling can occur if width/hieght does not match source
|
||||
* @param aX Horzontal left destination coordinate
|
||||
* @param aY Vertical top of destinatio coordinate
|
||||
* @param aWidth Width of destination,
|
||||
* @param aHeight Height of destination
|
||||
*/
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
|
||||
nscoord aWidth, nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext, scaling can occur if source/dest rects differ
|
||||
* @param aRect Destination rectangle to copy the image to
|
||||
*/
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect) = 0;
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext, scaling/clipping can occur if source/dest rects differ
|
||||
* @param aSRect Source rectangle to copy from
|
||||
* @param aDRect Destination rectangle to copy the image to
|
||||
*/
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)=0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext in a tiled manner
|
||||
* @param aImage image to copy
|
||||
* @param aX0 starting x
|
||||
* @param aY0 starting y
|
||||
* @param aX1 ending x
|
||||
* @param aY1 ending y
|
||||
* @param aWidth tile width
|
||||
* @param aHeight tile height
|
||||
*/
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth,nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Draw a path.. given a point array. The Path currently supported is a Quadratic
|
||||
* Bezier curve
|
||||
* @param aPointArray an array of points on the path
|
||||
* @param aNumPoints number of points in the array
|
||||
* @param aY0 starting y
|
||||
* @param aX1 ending x
|
||||
* @param aY1 ending y
|
||||
* @param aWidth tile width
|
||||
* @param aHeight tile height
|
||||
*/
|
||||
NS_IMETHOD DrawPath(nsPathPoint aPointArray[],PRInt32 aNumPts) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* fill a path.. given a point array. The Path currently supported is a Quadratic
|
||||
* Bezier curve
|
||||
* @param aPointArray an array of points on the path
|
||||
* @param aNumPts number of points in the array
|
||||
*/
|
||||
NS_IMETHOD FillPath(nsPathPoint aPointArray[],PRInt32 aNumPts) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Copy offscreen pixelmap to this RenderingContext.
|
||||
* @param aSrcSurf drawing surface to copy bits from
|
||||
* @param aSrcX x offset into source pixelmap to copy from
|
||||
* @param aSrcY y offset into source pixelmap to copy from
|
||||
* @param aDestBounds Destination rectangle to copy to
|
||||
* @param aCopyFlags see below
|
||||
*/
|
||||
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags) = 0;
|
||||
//~~~
|
||||
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd) = 0;
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext in a tiled manner
|
||||
* @param aImage image to copy
|
||||
* @param aSrcXOffset x offset inside the source image to begin tiling from
|
||||
* @param aSrcYOffset y offset inside the source image to begin tiling from
|
||||
* @param aTileRect area to tile
|
||||
*/
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
|
||||
nscoord aSrcYOffset, const nsRect &aTileRect) = 0;
|
||||
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
/**
|
||||
* Returns bounding metrics (in app units) of an 8-bit character string
|
||||
* @param aString string to measure
|
||||
* @param aLength number of characters in string
|
||||
* @return aBoundingMetrics struct that contains various metrics (see below)
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetBoundingMetrics(const char* aString,
|
||||
PRUint32 aLength,
|
||||
nsBoundingMetrics& aBoundingMetrics) = 0;
|
||||
/**
|
||||
* Returns bounding metrics (in app units) of an Unicode character string
|
||||
* @param aString string to measure
|
||||
* @param aLength number of characters in string
|
||||
* @param aFontID an optional out parameter used to store a
|
||||
* font identifier that can be passed into the GetBoundingMetrics()
|
||||
* methods to speed measurements
|
||||
* @return aBoundingMetrics struct that contains various metrics (see below)
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
nsBoundingMetrics& aBoundingMetrics,
|
||||
PRInt32* aFontID = nsnull) = 0;
|
||||
#endif
|
||||
|
||||
/* [noscript] void drawImage (in gfxIImageContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
|
||||
NS_IMETHOD DrawImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) = 0;
|
||||
|
||||
/* [noscript] void drawScaledImage (in gfxIImageContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
|
||||
NS_IMETHOD DrawScaledImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) = 0;
|
||||
|
||||
/* [noscript] void drawTile (in gfxIImageContainer aImage, in gfx_coord aXOffset, in gfx_coord aYOffset, [const] in nsRect aTargetRect); */
|
||||
NS_IMETHOD DrawTile(gfxIImageContainer *aImage, gfx_coord aXOffset, gfx_coord aYOffset, const nsRect * aTargetRect) = 0;
|
||||
|
||||
/* [noscript] void drawScaledTile (in gfxIImageContainer aImage, in gfx_coord aXOffset, in gfx_coord aYOffset, in gfx_dimension aTileWidth, in gfx_dimension aTileHeight, [const] in nsRect aTargetRect); */
|
||||
NS_IMETHOD DrawScaledTile(gfxIImageContainer *aImage, gfx_coord aXOffset, gfx_coord aYOffset, gfx_dimension aTileWidth, gfx_dimension aTileHeight, const nsRect * aTargetRect) = 0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
//modifiers for text rendering
|
||||
|
||||
#define NS_DRAWSTRING_NORMAL 0x0
|
||||
#define NS_DRAWSTRING_UNDERLINE 0x1
|
||||
#define NS_DRAWSTRING_OVERLINE 0x2
|
||||
#define NS_DRAWSTRING_LINE_THROUGH 0x4
|
||||
|
||||
// Bit values for GetHints
|
||||
|
||||
/**
|
||||
* This bit, when set, indicates that the underlying rendering system
|
||||
* prefers 8 bit text rendering over PRUnichar text rendering. When this
|
||||
* bit is <b>not</b> set the opposite is true: the system prefers PRUnichar
|
||||
* rendering, not 8 bit rendering.
|
||||
*/
|
||||
#define NS_RENDERING_HINT_FAST_8BIT_TEXT 0x1
|
||||
|
||||
/**
|
||||
* This bit, when set, indicates that the rendering is being done
|
||||
* remotely.
|
||||
*/
|
||||
#define NS_RENDERING_HINT_REMOTE_RENDERING 0x2
|
||||
|
||||
//flags for copy CopyOffScreenBits
|
||||
|
||||
//when performing the blit, use the region, if any,
|
||||
//that exists in the source drawingsurface as a
|
||||
//blit mask.
|
||||
#define NS_COPYBITS_USE_SOURCE_CLIP_REGION 0x0001
|
||||
|
||||
//transform the source offsets by the xform in the
|
||||
//rendering context
|
||||
#define NS_COPYBITS_XFORM_SOURCE_VALUES 0x0002
|
||||
|
||||
//transform the destination rect by the xform in the
|
||||
//rendering context
|
||||
#define NS_COPYBITS_XFORM_DEST_VALUES 0x0004
|
||||
|
||||
//this is basically a hack and is used by callers
|
||||
//who have selected an alternate drawing surface and
|
||||
//wish the copy to happen to that buffer rather than
|
||||
//the "front" buffer. i'm not proud of this. MMP
|
||||
//XXX: This is no longer needed by the XPCODE. It will
|
||||
//be removed once all of the platform specific nsRenderingContext's
|
||||
//stop using it.
|
||||
#define NS_COPYBITS_TO_BACK_BUFFER 0x0008
|
||||
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
/* Struct used for accurate measurements of a string in order
|
||||
to allow precise positioning when processing MathML.
|
||||
*/
|
||||
struct nsBoundingMetrics {
|
||||
|
||||
///////////
|
||||
// Metrics that _exactly_ enclose the text:
|
||||
|
||||
// The character coordinate system is the one used on X Windows:
|
||||
// 1. The origin is located at the intersection of the baseline
|
||||
// with the left of the character's cell.
|
||||
// 2. All horizontal bearings are oriented from left to right.
|
||||
// 3. The ascent is oriented from bottom to top (being 0 at the orgin).
|
||||
// 4. The descent is oriented from top to bottom (being 0 at the origin).
|
||||
|
||||
// Note that Win32/Mac/PostScript use a different convention for
|
||||
// the descent (all vertical measurements are oriented from bottom
|
||||
// to top on these palatforms). Make sure to flip to sign of the
|
||||
// descent on these platforms for cross-platform compatibility.
|
||||
|
||||
// Any of the following member variables listed here can have
|
||||
// positive or negative value.
|
||||
|
||||
nscoord leftBearing;
|
||||
/* The horizontal distance from the origin of the drawing
|
||||
operation to the left-most part of the drawn string. */
|
||||
|
||||
nscoord rightBearing;
|
||||
/* The horizontal distance from the origin of the drawing
|
||||
operation to the right-most part of the drawn string.
|
||||
The _exact_ width of the string is therefore:
|
||||
rightBearing - leftBearing */
|
||||
|
||||
nscoord ascent;
|
||||
/* The vertical distance from the origin of the drawing
|
||||
operation to the top-most part of the drawn string. */
|
||||
|
||||
nscoord descent;
|
||||
/* The vertical distance from the origin of the drawing
|
||||
operation to the bottom-most part of the drawn string.
|
||||
The _exact_ height of the string is therefore:
|
||||
ascent + descent */
|
||||
|
||||
//////////
|
||||
// Metrics for placing other surrounding text:
|
||||
|
||||
nscoord width;
|
||||
/* The horizontal distance from the origin of the drawing
|
||||
operation to the correct origin for drawing another string
|
||||
to follow the current one. Depending on the font, this
|
||||
could be greater than or less than the right bearing. */
|
||||
|
||||
nscoord supItalicCorrection, subItalicCorrection, leftItalicCorrection;
|
||||
/* The horizontal gaps between the string in slanted style
|
||||
(italic) and the same string in upright style (normal).
|
||||
|
||||
If the font was designed with an italic angle, then the
|
||||
subItalicCorrection (useful for attaching a subscript)
|
||||
is obtained by multiplying the tangent of the italic angle
|
||||
by the last character's descent.
|
||||
|
||||
The supItalicCorrection (useful for attaching a superscript)
|
||||
gives the amount of space to add after the italic string
|
||||
before immediately placing a superscript (or another string
|
||||
in and upright style).
|
||||
|
||||
These values are of opposite sign. For a forward-slanted
|
||||
font (italic style), supItalicCorrection >= 0 and
|
||||
subItalicCorrection <= 0.
|
||||
|
||||
For a back-slanted font, supItalicCorrection <= 0
|
||||
and subItalicCorrection >= 0.
|
||||
|
||||
The leftItalicCorrection gives the amount of space that should
|
||||
be added before the italic string when it is immediately to be
|
||||
preceded by an upright string.
|
||||
*/
|
||||
|
||||
//////////
|
||||
// Utility methods and operators:
|
||||
|
||||
/* Set all member data to zero */
|
||||
void
|
||||
Clear() {
|
||||
leftBearing = rightBearing = 0;
|
||||
ascent = descent = width = 0;
|
||||
supItalicCorrection = subItalicCorrection = 0;
|
||||
leftItalicCorrection = 0;
|
||||
}
|
||||
|
||||
/* Append another bounding metrics */
|
||||
/* Notice that leftBearing and leftItalicCorrection are not set.
|
||||
The user must set leftBearing and leftItalicCorrection on
|
||||
initialization and (repeatedly) use this operator to append
|
||||
other bounding metrics on the right.
|
||||
*/
|
||||
void
|
||||
operator += (const nsBoundingMetrics& bm) {
|
||||
if (ascent < bm.ascent) ascent = bm.ascent;
|
||||
if (descent < bm.descent) descent = bm.descent;
|
||||
rightBearing = width + bm.rightBearing;
|
||||
width += bm.width;
|
||||
supItalicCorrection = bm.supItalicCorrection;
|
||||
subItalicCorrection = bm.subItalicCorrection;
|
||||
}
|
||||
};
|
||||
#endif // MOZ_MATHML
|
||||
|
||||
#endif /* nsIRenderingContext_h___ */
|
||||
75
mozilla/gfx/public/nsMargin.h
Normal file
75
mozilla/gfx/public/nsMargin.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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 */
|
||||
125
mozilla/gfx/public/nsPoint.h
Normal file
125
mozilla/gfx/public/nsPoint.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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 */
|
||||
136
mozilla/gfx/public/nsRect.h
Normal file
136
mozilla/gfx/public/nsRect.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
|
||||
#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 width or height
|
||||
// is <= 0
|
||||
PRBool IsEmpty() const {
|
||||
return (PRBool) ((width <= 0) || (height <= 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 */
|
||||
202
mozilla/gfx/public/nsRenderingContextImpl.h
Normal file
202
mozilla/gfx/public/nsRenderingContextImpl.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsRenderingContextImpl_h___
|
||||
#define nsRenderingContextImpl_h___
|
||||
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsPoint.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 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
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 03/29/00 dwc
|
||||
*/
|
||||
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);
|
||||
/** ---------------------------------------------------
|
||||
* 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 DrawImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
|
||||
NS_IMETHOD DrawScaledImage(gfxIImageContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
|
||||
NS_IMETHOD DrawTile(gfxIImageContainer *aImage, gfx_coord aXOffset, gfx_coord aYOffset, const nsRect * aTargetRect);
|
||||
NS_IMETHOD DrawScaledTile(gfxIImageContainer *aImage, gfx_coord aXOffset, gfx_coord aYOffset, gfx_dimension aTileWidth, gfx_dimension aTileHeight, const nsRect * aTargetRect);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* 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 */
|
||||
66
mozilla/gfx/public/nsRepeater.h
Normal file
66
mozilla/gfx/public/nsRepeater.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsRepeater_h___
|
||||
#define nsRepeater_h___
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class EventRecord;
|
||||
|
||||
class NS_NET 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
|
||||
65
mozilla/gfx/public/nsSize.h
Normal file
65
mozilla/gfx/public/nsSize.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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 */
|
||||
226
mozilla/gfx/public/nsTransform2D.h
Normal file
226
mozilla/gfx/public/nsTransform2D.h
Normal file
@@ -0,0 +1,226 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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); }
|
||||
|
||||
/**
|
||||
* 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
|
||||
2
mozilla/gfx/src/MANIFEST
Normal file
2
mozilla/gfx/src/MANIFEST
Normal file
@@ -0,0 +1,2 @@
|
||||
icon_0.gif
|
||||
icon_1.gif
|
||||
107
mozilla/gfx/src/Makefile.in
Normal file
107
mozilla/gfx/src/Makefile.in
Normal file
@@ -0,0 +1,107 @@
|
||||
#
|
||||
# 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 = layout
|
||||
LIBRARY_NAME = gkgfx
|
||||
REQUIRES = xpcom img widget util dom locale view necko pref js timer uriloader
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
DIRS =
|
||||
else
|
||||
DIRS = ps
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_XPRINT
|
||||
DIRS += xprint
|
||||
endif
|
||||
|
||||
# Build xlibrgb only for X toolkits
|
||||
ifneq (,$(filter motif xlib,$(MOZ_WIDGET_TOOLKIT))$(MOZ_ENABLE_XLIB))
|
||||
DIRS += xlibrgb
|
||||
endif
|
||||
|
||||
ifdef MOZ_MONOLITHIC_TOOLKIT
|
||||
DIRS += $(MOZ_GFX_TOOLKIT)
|
||||
else
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
DIRS += gtk
|
||||
endif
|
||||
ifdef MOZ_ENABLE_MOTIF
|
||||
DIRS += motif
|
||||
endif
|
||||
ifdef MOZ_ENABLE_QT
|
||||
DIRS += qt
|
||||
endif
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
DIRS += xlib
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_PHOTON
|
||||
DIRS += photon
|
||||
endif
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
nsBlender.cpp \
|
||||
nsColor.cpp \
|
||||
nsColorNames.cpp \
|
||||
nsDeviceContext.cpp \
|
||||
nsFont.cpp \
|
||||
nsImageGroup.cpp \
|
||||
nsImageManager.cpp \
|
||||
nsImageNetContextAsync.cpp \
|
||||
nsImageNetContextSync.cpp \
|
||||
nsImageRenderer.cpp \
|
||||
nsRenderingContextImpl.cpp \
|
||||
nsImageRequest.cpp \
|
||||
nsImageSystemServices.cpp \
|
||||
nsImageURL.cpp \
|
||||
nsRect.cpp \
|
||||
nsTransform2D.cpp \
|
||||
nsScriptableRegion.cpp \
|
||||
nsGraphicsImpl.cpp \
|
||||
nsPrintOptionsImpl.cpp \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libimg_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/libmozutil_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFX
|
||||
|
||||
install:: icon_0.gif icon_1.gif
|
||||
$(INSTALL) -m 555 $^ $(DIST)/bin/res/gfx
|
||||
|
||||
63
mozilla/gfx/src/beos/Makefile.in
Normal file
63
mozilla/gfx/src/beos/Makefile.in
Normal file
@@ -0,0 +1,63 @@
|
||||
#
|
||||
# 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 = layout
|
||||
LIBRARY_NAME = gfx_beos
|
||||
IS_COMPONENT = 1
|
||||
|
||||
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 \
|
||||
$(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)
|
||||
525
mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp
Normal file
525
mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp
Normal file
@@ -0,0 +1,525 @@
|
||||
/* -*- 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):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "il_util.h"
|
||||
#include "nsCRT.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;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextBeOS, nsIDeviceContext)
|
||||
|
||||
nsDeviceContextBeOS::nsDeviceContextBeOS()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mTwipsToPixels = 1.0;
|
||||
mPixelsToTwips = 1.0;
|
||||
mDepth = 0 ;
|
||||
mPaletteInfo.isPaletteDevice = PR_FALSE;
|
||||
mPaletteInfo.sizePalette = 0;
|
||||
mPaletteInfo.numReserved = 0;
|
||||
mPaletteInfo.palette = NULL;
|
||||
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;
|
||||
|
||||
NS_WITH_SERVICE(nsIPref, prefs, 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::GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
|
||||
switch (anID) {
|
||||
//---------
|
||||
// Colors
|
||||
//---------
|
||||
case eSystemAttr_Color_WindowBackground:
|
||||
*aInfo->mColor = NS_RGB(0xdd,0xdd,0xdd);
|
||||
break;
|
||||
case eSystemAttr_Color_WindowForeground:
|
||||
*aInfo->mColor = NS_RGB(0x00,0x00,0x00);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetBackground:
|
||||
*aInfo->mColor = NS_RGB(0xdd,0xdd,0xdd);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetForeground:
|
||||
*aInfo->mColor = NS_RGB(0x00,0x00,0x00);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetSelectBackground:
|
||||
*aInfo->mColor = NS_RGB(0x80,0x80,0x80);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetSelectForeground:
|
||||
*aInfo->mColor = NS_RGB(0x00,0x00,0x80);
|
||||
break;
|
||||
case eSystemAttr_Color_Widget3DHighlight:
|
||||
*aInfo->mColor = NS_RGB(0xa0,0xa0,0xa0);
|
||||
break;
|
||||
case eSystemAttr_Color_Widget3DShadow:
|
||||
*aInfo->mColor = NS_RGB(0x40,0x40,0x40);
|
||||
break;
|
||||
case eSystemAttr_Color_TextBackground:
|
||||
*aInfo->mColor = NS_RGB(0xff,0xff,0xff);
|
||||
break;
|
||||
case eSystemAttr_Color_TextForeground:
|
||||
*aInfo->mColor = NS_RGB(0x00,0x00,0x00);
|
||||
break;
|
||||
case eSystemAttr_Color_TextSelectBackground:
|
||||
*aInfo->mColor = NS_RGB(0x00,0x00,0x80);
|
||||
break;
|
||||
case eSystemAttr_Color_TextSelectForeground:
|
||||
*aInfo->mColor = NS_RGB(0xff,0xff,0xff);
|
||||
break;
|
||||
//---------
|
||||
// Size
|
||||
//---------
|
||||
case eSystemAttr_Size_ScrollbarHeight:
|
||||
aInfo->mSize = mScrollbarHeight;
|
||||
break;
|
||||
case eSystemAttr_Size_ScrollbarWidth :
|
||||
aInfo->mSize = mScrollbarWidth;
|
||||
break;
|
||||
case eSystemAttr_Size_WindowTitleHeight:
|
||||
aInfo->mSize = 0;
|
||||
break;
|
||||
case eSystemAttr_Size_WindowBorderWidth:
|
||||
aInfo->mSize = 5; // need to be checked!
|
||||
break;
|
||||
case eSystemAttr_Size_WindowBorderHeight:
|
||||
aInfo->mSize = 5; // need to be checked!
|
||||
break;
|
||||
case eSystemAttr_Size_Widget3DBorder:
|
||||
aInfo->mSize = 4;
|
||||
break;
|
||||
//---------
|
||||
// Fonts
|
||||
//---------
|
||||
case eSystemAttr_Font_Caption: // css2
|
||||
case eSystemAttr_Font_Icon :
|
||||
case eSystemAttr_Font_Menu :
|
||||
case eSystemAttr_Font_MessageBox :
|
||||
case eSystemAttr_Font_SmallCaption :
|
||||
case eSystemAttr_Font_StatusBar :
|
||||
case eSystemAttr_Font_Window: // css3
|
||||
case eSystemAttr_Font_Document:
|
||||
case eSystemAttr_Font_Workspace:
|
||||
case eSystemAttr_Font_Desktop:
|
||||
case eSystemAttr_Font_Info:
|
||||
case eSystemAttr_Font_Dialog:
|
||||
case eSystemAttr_Font_Button:
|
||||
case eSystemAttr_Font_PullDownMenu:
|
||||
case eSystemAttr_Font_List:
|
||||
case eSystemAttr_Font_Field:
|
||||
case eSystemAttr_Font_Tooltips: // moz
|
||||
case eSystemAttr_Font_Widget:
|
||||
status = GetSystemFontInfo(be_plain_font, anID, aInfo->mFont);
|
||||
break;
|
||||
} // switch
|
||||
|
||||
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 = aFontName.ToNewCString();
|
||||
|
||||
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;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
rv = prefs->GetIntPref(aPref, &dpi);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
context->SetDPI(dpi);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContextBeOS::GetSystemFontInfo(const BFont *theFont, nsSystemAttrID 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);
|
||||
}
|
||||
99
mozilla/gfx/src/beos/nsDeviceContextBeOS.h
Normal file
99
mozilla/gfx/src/beos/nsDeviceContextBeOS.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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_DECL_ISUPPORTS
|
||||
|
||||
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 GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) 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;
|
||||
nsPaletteInfo mPaletteInfo;
|
||||
PRUint32 mNumCells;
|
||||
PRInt16 mScrollbarHeight;
|
||||
PRInt16 mScrollbarWidth;
|
||||
static nscoord mDpi;
|
||||
|
||||
float mWidthFloat;
|
||||
float mHeightFloat;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
|
||||
nsresult GetSystemFontInfo(const BFont *font, nsSystemAttrID anID, nsFont* aFont) const;
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextBeOS_h___ */
|
||||
|
||||
313
mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp
Normal file
313
mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp
Normal file
@@ -0,0 +1,313 @@
|
||||
/* -*- 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 "nsDeviceContextSpecB.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIAppShellComponentImpl.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsINetSupportDialogService.h"
|
||||
|
||||
static NS_DEFINE_IID( kAppShellServiceCID, NS_APPSHELL_SERVICE_CID );
|
||||
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
|
||||
//#include "prmem.h"
|
||||
//#include "plstr.h"
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* 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_QUERY_INTERFACE(nsDeviceContextSpecBeOS, kDeviceContextSpecIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecBeOS)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecBeOS)
|
||||
#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)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the nsDeviceContextSpecBeOS
|
||||
* @update dc 2/15/98
|
||||
* @update syd 3/2/99
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: Init(PRBool aQuiet)
|
||||
{
|
||||
char *path;
|
||||
|
||||
PRBool reversed = PR_FALSE, color = PR_FALSE, landscape = PR_FALSE;
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt32 paper_size = NS_LETTER_SIZE;
|
||||
int ileft = 500, iright = 0, itop = 500, ibottom = 0;
|
||||
char *command;
|
||||
char *printfile = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kDialogParamBlockCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDialogParamBlock),
|
||||
getter_AddRefs(ioParamBlock));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> hiddenWindow;
|
||||
nsCOMPtr<nsIDOMWindowInternal> mWindow;
|
||||
|
||||
JSContext *jsContext;
|
||||
rv = appShell->GetHiddenWindowAndJSContext(getter_AddRefs(hiddenWindow), &jsContext);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
void *stackPtr;
|
||||
jsval *argv = JS_PushArguments(jsContext,
|
||||
&stackPtr,
|
||||
"sss%ip",
|
||||
"chrome://global/content/printdialog.xul",
|
||||
"_blank",
|
||||
"chrome,modal",
|
||||
(const nsIID *) (&NS_GET_IID(nsIDialogParamBlock)),
|
||||
(nsISupports *) ioParamBlock);
|
||||
if (argv) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> newWindow;
|
||||
|
||||
rv = hiddenWindow->OpenDialog(jsContext,
|
||||
argv,
|
||||
4,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
JS_PopArguments(jsContext, stackPtr);
|
||||
PRInt32 buttonPressed = 0;
|
||||
ioParamBlock->GetInt(0, &buttonPressed);
|
||||
if (buttonPressed == 0) {
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pPrefs) {
|
||||
(void) pPrefs->GetBoolPref("print.print_reversed", &reversed);
|
||||
(void) pPrefs->GetBoolPref("print.print_color", &color);
|
||||
(void) pPrefs->GetBoolPref("print.print_landscape", &landscape);
|
||||
(void) pPrefs->GetIntPref("print.print_paper_size", &paper_size);
|
||||
(void) pPrefs->CopyCharPref("print.print_command", (char **) &command);
|
||||
(void) pPrefs->GetIntPref("print.print_margin_top", &itop);
|
||||
(void) pPrefs->GetIntPref("print.print_margin_left", &ileft);
|
||||
(void) pPrefs->GetIntPref("print.print_margin_bottom", &ibottom);
|
||||
(void) pPrefs->GetIntPref("print.print_margin_right", &iright);
|
||||
(void) pPrefs->CopyCharPref("print.print_file", (char **) &printfile);
|
||||
(void) pPrefs->GetBoolPref("print.print_tofile", &tofile);
|
||||
sprintf( mPrData.command, command );
|
||||
sprintf( mPrData.path, printfile );
|
||||
} else {
|
||||
#ifndef VMS
|
||||
sprintf( mPrData.command, "lpr" );
|
||||
#else
|
||||
// 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.
|
||||
sprintf( mPrData.command, "print" );
|
||||
#endif
|
||||
}
|
||||
|
||||
mPrData.top = itop / 1000.0;
|
||||
mPrData.bottom = ibottom / 1000.0;
|
||||
mPrData.left = ileft / 1000.0;
|
||||
mPrData.right = iright / 1000.0;
|
||||
mPrData.fpf = !reversed;
|
||||
mPrData.grayscale = !color;
|
||||
mPrData.size = paper_size;
|
||||
mPrData.toPrinter = !tofile;
|
||||
|
||||
// PWD, HOME, or fail
|
||||
|
||||
if (!printfile) {
|
||||
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL )
|
||||
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL )
|
||||
strcpy( mPrData.path, "mozilla.ps" );
|
||||
if ( path != (char *) NULL )
|
||||
sprintf( mPrData.path, "%s/mozilla.ps", path );
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetToPrinter( PRBool &aToPrinter )
|
||||
{
|
||||
aToPrinter = mPrData.toPrinter;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
101
mozilla/gfx/src/beos/nsDeviceContextSpecB.h
Normal file
101
mozilla/gfx/src/beos/nsDeviceContextSpecB.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsDeviceContextSpecB_h___
|
||||
#define nsDeviceContextSpecB_h___
|
||||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsDeviceContextSpecB.h"
|
||||
#include "nsIDeviceContextSpecPS.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(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 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 GetUserCancelled( PRBool &aCancel );
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
virtual ~nsDeviceContextSpecBeOS();
|
||||
|
||||
protected:
|
||||
|
||||
BeOSPrData mPrData;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
82
mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.cpp
Normal file
82
mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#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(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryBeOS, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryBeOS)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryBeOS)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* 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,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIDeviceContextSpec *devSpec = nsnull;
|
||||
|
||||
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
|
||||
|
||||
if (nsnull != devSpec){
|
||||
if (NS_OK == ((nsDeviceContextSpecBeOS *)devSpec)->Init(aQuiet)){
|
||||
aNewSpec = devSpec;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
45
mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.h
Normal file
45
mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#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,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryBeOS();
|
||||
};
|
||||
|
||||
#endif
|
||||
261
mozilla/gfx/src/beos/nsDrawingSurfaceBeOS.cpp
Normal file
261
mozilla/gfx/src/beos/nsDrawingSurfaceBeOS.cpp
Normal file
@@ -0,0 +1,261 @@
|
||||
/* -*- 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 "nsDrawingSurfaceBeOS.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());
|
||||
mHeight=nscoord(aView->Bounds().Height());
|
||||
|
||||
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 = aView->Bounds();
|
||||
mView = new BView(r, "", 0, 0);
|
||||
if (mView==NULL)
|
||||
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==NULL)
|
||||
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;
|
||||
}
|
||||
87
mozilla/gfx/src/beos/nsDrawingSurfaceBeOS.h
Normal file
87
mozilla/gfx/src/beos/nsDrawingSurfaceBeOS.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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
|
||||
468
mozilla/gfx/src/beos/nsFontMetricsBeOS.cpp
Normal file
468
mozilla/gfx/src/beos/nsFontMetricsBeOS.cpp
Normal file
@@ -0,0 +1,468 @@
|
||||
/* -*- 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 "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"
|
||||
|
||||
#undef USER_DEFINED
|
||||
#define USER_DEFINED "x-user-def"
|
||||
|
||||
#undef NOISY_FONTS
|
||||
#undef REALLY_NOISY_FONTS
|
||||
|
||||
nsFontMetricsBeOS::nsFontMetricsBeOS()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsFontMetricsBeOS::~nsFontMetricsBeOS()
|
||||
{
|
||||
if (nsnull != mFont) {
|
||||
delete mFont;
|
||||
mFont = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFontMetricsBeOS, nsIFontMetrics)
|
||||
|
||||
static PRBool
|
||||
IsASCIIFontName(const nsString& aName)
|
||||
{
|
||||
PRUint32 len = aName.Length();
|
||||
const PRUnichar* str = aName.GetUnicode();
|
||||
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;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIDeviceContext* aContext)
|
||||
{
|
||||
NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");
|
||||
|
||||
nsAutoString firstFace;
|
||||
mLangGroup = aLangGroup;
|
||||
if (NS_OK != aContext->FirstExistingFont(aFont, firstFace)) {
|
||||
aFont.GetFirstFamily(firstFace);
|
||||
}
|
||||
|
||||
// PRInt32 namelen = MAX( firstFace.Length() + 1, sizeof(font_family) );
|
||||
font_family wildstring;
|
||||
PRInt16 face = B_REGULAR_FACE;
|
||||
|
||||
mFont = new nsFont(aFont);
|
||||
|
||||
float app2dev, app2twip;
|
||||
aContext->GetAppUnitsToDevUnits(app2dev);
|
||||
aContext->GetDevUnitsToTwips(app2twip);
|
||||
|
||||
app2twip *= app2dev;
|
||||
float rounded = ((float)NSIntPointsToTwips(NSTwipsToFloorIntPoints(nscoord(mFont->size * app2twip)))) / app2twip;
|
||||
#if 0
|
||||
nsNativeWidget widget = nsnull;
|
||||
aContext->GetNativeWidget(widget);
|
||||
if( widget ) {
|
||||
BView *view = dynamic_cast<BView*>( (BView*)widget );
|
||||
view->GetFont( &mFontHandle );
|
||||
}
|
||||
|
||||
firstFace.ToCString(wildstring, namelen);
|
||||
|
||||
#if 1
|
||||
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 ) {
|
||||
int32 numStyles = count_font_styles(family);
|
||||
for ( int32 j = 0; j < numStyles; j++ ) {
|
||||
font_style style;
|
||||
if ( get_font_style(family, j, &style, &flags)
|
||||
== B_OK ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aFont.style == NS_FONT_STYLE_ITALIC)
|
||||
face = B_ITALIC_FACE;
|
||||
|
||||
if( aFont.weight > NS_FONT_WEIGHT_NORMAL )
|
||||
face |= B_BOLD_FACE;
|
||||
|
||||
if( aFont.decorations & NS_FONT_DECORATION_UNDERLINE )
|
||||
face |= B_UNDERSCORE_FACE;
|
||||
|
||||
if( aFont.decorations & NS_FONT_DECORATION_LINE_THROUGH )
|
||||
face |= B_STRIKEOUT_FACE;
|
||||
#endif
|
||||
|
||||
mFontHandle.SetFamilyAndFace( wildstring, face );
|
||||
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()
|
||||
{
|
||||
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::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.GetUnicode());
|
||||
name.ToLowerCase();
|
||||
PRBool isthere = PR_FALSE;
|
||||
|
||||
char* cStr = name.ToNewCString();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFontMetricsBeOS::GetSpaceWidth(nscoord &aSpaceWidth)
|
||||
{
|
||||
aSpaceWidth = mSpaceWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The Font Enumerator
|
||||
|
||||
nsFontEnumeratorBeOS::nsFontEnumeratorBeOS()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsFontEnumeratorBeOS,
|
||||
NS_GET_IID(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] = font_name.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
117
mozilla/gfx/src/beos/nsFontMetricsBeOS.h
Normal file
117
mozilla/gfx/src/beos/nsFontMetricsBeOS.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#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);
|
||||
|
||||
virtual nsresult GetSpaceWidth(nscoord &aSpaceWidth);
|
||||
|
||||
static nsresult FamilyExists(const nsString& aFontName);
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class nsFontEnumeratorBeOS : public nsIFontEnumerator
|
||||
{
|
||||
public:
|
||||
nsFontEnumeratorBeOS();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFONTENUMERATOR
|
||||
};
|
||||
|
||||
#endif
|
||||
176
mozilla/gfx/src/beos/nsGfxFactoryBeOS.cpp
Normal file
176
mozilla/gfx/src/beos/nsGfxFactoryBeOS.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
/* -*- 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 "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 "nsIImageManager.h"
|
||||
#include "nsDeviceContextBeOS.h"
|
||||
#include "nsImageBeOS.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(nsScreenManagerBeOS)
|
||||
|
||||
// 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, nsRegionBeOS);
|
||||
if (rgn != nsnull)
|
||||
{
|
||||
nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(rgn);
|
||||
inst = scriptableRgn;
|
||||
}
|
||||
if (!inst)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(inst);
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(inst);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult nsImageManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if ( !aResult )
|
||||
{
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = nsnull;
|
||||
if (aOuter)
|
||||
{
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
// this will return an image manager with a count of 1
|
||||
rv = NS_NewImageManager((nsIImageManager **)aResult);
|
||||
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/gtk;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 },
|
||||
{ "Image Manager",
|
||||
NS_IMAGEMANAGER_CID,
|
||||
// "@mozilla.org/gfx/image_manager;1",
|
||||
"@mozilla.org/gfx/imagemanager;1",
|
||||
nsImageManagerConstructor },
|
||||
{ "BeOS Font Enumerator",
|
||||
NS_FONT_ENUMERATOR_CID,
|
||||
// "@mozilla.org/gfx/font_enumerator/beos;1",
|
||||
"@mozilla.org/gfx/fontenumerator;1",
|
||||
nsFontEnumeratorBeOSConstructor },
|
||||
{ "BeOS Screen Manager",
|
||||
NS_SCREENMANAGER_CID,
|
||||
// "@mozilla.org/gfx/screenmanager/beos;1",
|
||||
"@mozilla.org/gfx/screenmanager;1",
|
||||
nsScreenManagerBeOSConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsGfxBeOSModule", components)
|
||||
125
mozilla/gfx/src/beos/nsGraphicsStateBeOS.cpp
Normal file
125
mozilla/gfx/src/beos/nsGraphicsStateBeOS.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
/* -*- 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 "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;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
75
mozilla/gfx/src/beos/nsGraphicsStateBeOS.h
Normal file
75
mozilla/gfx/src/beos/nsGraphicsStateBeOS.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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___ */
|
||||
68
mozilla/gfx/src/beos/nsIDrawingSurfaceBeOS.h
Normal file
68
mozilla/gfx/src/beos/nsIDrawingSurfaceBeOS.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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___
|
||||
546
mozilla/gfx/src/beos/nsImageBeOS.cpp
Normal file
546
mozilla/gfx/src/beos/nsImageBeOS.cpp
Normal file
@@ -0,0 +1,546 @@
|
||||
/* -*- 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 "nsImageBeOS.h"
|
||||
#include "nsRenderingContextBeOS.h"
|
||||
|
||||
#include "nspr.h"
|
||||
//#include <string.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[8 * mAlphaRowBytes * aHeight];
|
||||
memset(mAlphaBits, 255, 8*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->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->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;
|
||||
}
|
||||
|
||||
159
mozilla/gfx/src/beos/nsImageBeOS.h
Normal file
159
mozilla/gfx/src/beos/nsImageBeOS.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsImageBeOS_h___
|
||||
#define nsImageBeOS_h___
|
||||
|
||||
#include "nsIImage.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);
|
||||
|
||||
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();
|
||||
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
|
||||
68
mozilla/gfx/src/beos/nsPrintdBeOS.h
Normal file
68
mozilla/gfx/src/beos/nsPrintdBeOS.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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):
|
||||
*/
|
||||
|
||||
/* 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
|
||||
#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 */
|
||||
char command[ PATH_MAX ]; /* Print command e.g., lpr */
|
||||
char path[ PATH_MAX ]; /* If toPrinter = PR_FALSE, dest file */
|
||||
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 /* nsPrintdBeOS_h___ */
|
||||
246
mozilla/gfx/src/beos/nsRegionBeOS.cpp
Normal file
246
mozilla/gfx/src/beos/nsRegionBeOS.cpp
Normal file
@@ -0,0 +1,246 @@
|
||||
/* -*- 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 <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)
|
||||
{
|
||||
printf(" - nsRegionBeOS :: IsEqual not implemented!\n");
|
||||
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());
|
||||
*aHeight = nscoord(rect.Height());
|
||||
}
|
||||
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;
|
||||
}
|
||||
69
mozilla/gfx/src/beos/nsRegionBeOS.h
Normal file
69
mozilla/gfx/src/beos/nsRegionBeOS.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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___
|
||||
1375
mozilla/gfx/src/beos/nsRenderingContextBeOS.cpp
Normal file
1375
mozilla/gfx/src/beos/nsRenderingContextBeOS.cpp
Normal file
File diff suppressed because it is too large
Load Diff
223
mozilla/gfx/src/beos/nsRenderingContextBeOS.h
Normal file
223
mozilla/gfx/src/beos/nsRenderingContextBeOS.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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 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___ */
|
||||
119
mozilla/gfx/src/beos/nsScreenBeOS.cpp
Normal file
119
mozilla/gfx/src/beos/nsScreenBeOS.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "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_ISUPPORTS(nsScreenBeOS, NS_GET_IID(nsIScreen))
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenBeOS :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||
{
|
||||
BScreen screen;
|
||||
|
||||
*outTop = 0;
|
||||
*outLeft = 0;
|
||||
*outWidth = PRInt32(screen.Frame().Width());
|
||||
*outHeight = PRInt32(screen.Frame().Height());
|
||||
|
||||
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());
|
||||
*outHeight = PRInt32(screen.Frame().Height());
|
||||
|
||||
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:
|
||||
printf("FIXME: Please add this screen depth to the code nsScreenBeOS.cpp\n");
|
||||
pixelDepth = 32;
|
||||
break;
|
||||
}
|
||||
*aPixelDepth = pixelDepth;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetPixelDepth
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenBeOS :: GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
return GetPixelDepth ( aColorDepth );
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
|
||||
43
mozilla/gfx/src/beos/nsScreenBeOS.h
Normal file
43
mozilla/gfx/src/beos/nsScreenBeOS.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef 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___
|
||||
112
mozilla/gfx/src/beos/nsScreenManagerBeOS.cpp
Normal file
112
mozilla/gfx/src/beos/nsScreenManagerBeOS.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "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_ISUPPORTS(nsScreenManagerBeOS, NS_GET_IID(nsIScreenManager))
|
||||
|
||||
|
||||
//
|
||||
// CreateNewScreenObject
|
||||
//
|
||||
// Utility routine. Creates a new screen object from the given device handle
|
||||
//
|
||||
// NOTE: For this "single-monitor" impl, we just always return the cached primary
|
||||
// screen. This should change when a multi-monitor impl is done.
|
||||
//
|
||||
nsIScreen*
|
||||
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
|
||||
|
||||
50
mozilla/gfx/src/beos/nsScreenManagerBeOS.h
Normal file
50
mozilla/gfx/src/beos/nsScreenManagerBeOS.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef 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___
|
||||
99
mozilla/gfx/src/gtk/Makefile.in
Normal file
99
mozilla/gfx/src/gtk/Makefile.in
Normal file
@@ -0,0 +1,99 @@
|
||||
#
|
||||
# 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 = layout
|
||||
LIBRARY_NAME = gfx_gtk
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom img widget view util dom pref js uconv appshell necko unicharutil
|
||||
|
||||
CSRCS = nsPrintdGTK.c
|
||||
|
||||
CPPSRCS = \
|
||||
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)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
endif
|
||||
|
||||
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
|
||||
endif
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/. \
|
||||
-I$(srcdir)/.. \
|
||||
$(NULL)
|
||||
|
||||
649
mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp
Normal file
649
mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp
Normal file
@@ -0,0 +1,649 @@
|
||||
/* -*- 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 <math.h>
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "il_util.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
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
#endif
|
||||
|
||||
#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;
|
||||
|
||||
nscoord nsDeviceContextGTK::mDpi = 96;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextGTK, nsIDeviceContext)
|
||||
|
||||
nsDeviceContextGTK::nsDeviceContextGTK()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mTwipsToPixels = 1.0;
|
||||
mPixelsToTwips = 1.0;
|
||||
mDepth = 0 ;
|
||||
mPaletteInfo.isPaletteDevice = PR_FALSE;
|
||||
mPaletteInfo.sizePalette = 0;
|
||||
mPaletteInfo.numReserved = 0;
|
||||
mPaletteInfo.palette = NULL;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
|
||||
nsresult ignore;
|
||||
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;
|
||||
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;
|
||||
|
||||
NS_WITH_SERVICE(nsIPref, prefs, 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.
|
||||
float screenWidthIn = float(::gdk_screen_width_mm()) / 25.4f;
|
||||
PRInt32 OSVal = nscoord(mWidthFloat / screenWidthIn);
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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::GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
GtkStyle *style = gtk_style_new(); // get the default styles
|
||||
|
||||
switch (anID) {
|
||||
//---------
|
||||
// Colors
|
||||
//---------
|
||||
case eSystemAttr_Color_WindowBackground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
||||
break;
|
||||
case eSystemAttr_Color_WindowForeground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetBackground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetForeground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetSelectBackground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
|
||||
break;
|
||||
case eSystemAttr_Color_WidgetSelectForeground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_SELECTED]);
|
||||
break;
|
||||
case eSystemAttr_Color_Widget3DHighlight:
|
||||
*aInfo->mColor = NS_RGB(0xa0,0xa0,0xa0);
|
||||
break;
|
||||
case eSystemAttr_Color_Widget3DShadow:
|
||||
*aInfo->mColor = NS_RGB(0x40,0x40,0x40);
|
||||
break;
|
||||
case eSystemAttr_Color_TextBackground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
|
||||
break;
|
||||
case eSystemAttr_Color_TextForeground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
|
||||
break;
|
||||
case eSystemAttr_Color_TextSelectBackground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
|
||||
break;
|
||||
case eSystemAttr_Color_TextSelectForeground:
|
||||
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->text[GTK_STATE_SELECTED]);
|
||||
break;
|
||||
//---------
|
||||
// Size
|
||||
//---------
|
||||
case eSystemAttr_Size_ScrollbarHeight:
|
||||
aInfo->mSize = mScrollbarHeight;
|
||||
break;
|
||||
case eSystemAttr_Size_ScrollbarWidth:
|
||||
aInfo->mSize = mScrollbarWidth;
|
||||
break;
|
||||
case eSystemAttr_Size_WindowTitleHeight:
|
||||
aInfo->mSize = 0;
|
||||
break;
|
||||
case eSystemAttr_Size_WindowBorderWidth:
|
||||
aInfo->mSize = style->klass->xthickness;
|
||||
break;
|
||||
case eSystemAttr_Size_WindowBorderHeight:
|
||||
aInfo->mSize = style->klass->ythickness;
|
||||
break;
|
||||
case eSystemAttr_Size_Widget3DBorder:
|
||||
aInfo->mSize = 4;
|
||||
break;
|
||||
//---------
|
||||
// Fonts
|
||||
//---------
|
||||
case eSystemAttr_Font_Caption: // css2
|
||||
case eSystemAttr_Font_Icon:
|
||||
case eSystemAttr_Font_Menu:
|
||||
case eSystemAttr_Font_MessageBox:
|
||||
case eSystemAttr_Font_SmallCaption:
|
||||
case eSystemAttr_Font_StatusBar:
|
||||
case eSystemAttr_Font_Window: // css3
|
||||
case eSystemAttr_Font_Document:
|
||||
case eSystemAttr_Font_Workspace:
|
||||
case eSystemAttr_Font_Desktop:
|
||||
case eSystemAttr_Font_Info:
|
||||
case eSystemAttr_Font_Dialog:
|
||||
case eSystemAttr_Font_Button:
|
||||
case eSystemAttr_Font_PullDownMenu:
|
||||
case eSystemAttr_Font_List:
|
||||
case eSystemAttr_Font_Field:
|
||||
case eSystemAttr_Font_Tooltips: // moz
|
||||
case eSystemAttr_Font_Widget:
|
||||
status = GetSystemFontInfo(style->font, anID, aInfo->mFont);
|
||||
break;
|
||||
} // switch
|
||||
|
||||
gtk_style_unref(style);
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
#ifdef USE_XPRINT
|
||||
int method=-1;
|
||||
nsDeviceContextSpecGTK* spec=(nsDeviceContextSpecGTK*)aDevice;
|
||||
spec->GetPrintMethod(method);
|
||||
|
||||
if (method == 1) { // XPRINT
|
||||
static NS_DEFINE_CID(kCDeviceContextXP, NS_DEVICECONTEXTXP_CID);
|
||||
nsresult rv;
|
||||
nsIDeviceContextXP *dcxp;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCDeviceContextXP,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDeviceContextXP),
|
||||
(void **)&dcxp);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create XP Device context");
|
||||
|
||||
dcxp->SetSpec(aDevice);
|
||||
dcxp->InitDeviceContextXP((nsIDeviceContext*)aContext,
|
||||
(nsIDeviceContext*)this);
|
||||
|
||||
rv = dcxp->QueryInterface(NS_GET_IID(nsIDeviceContext),
|
||||
(void **)&aContext);
|
||||
|
||||
NS_RELEASE(dcxp);
|
||||
|
||||
return rv;
|
||||
}
|
||||
// default/PS
|
||||
#endif
|
||||
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 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 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 nsDeviceContextGTK::prefChanged(const char *aPref, void *aClosure)
|
||||
{
|
||||
nsDeviceContextGTK *context = (nsDeviceContextGTK*)aClosure;
|
||||
nsresult rv;
|
||||
|
||||
if (nsCRT::strcmp(aPref, "browser.display.screen_resolution")==0) {
|
||||
PRInt32 dpi;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
rv = prefs->GetIntPref(aPref, &dpi);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
context->SetDPI(dpi);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContextGTK::GetSystemFontInfo( GdkFont* iFont, nsSystemAttrID anID, nsFont* aFont) const
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
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 )
|
||||
{
|
||||
status = NS_ERROR_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *fontName = (char *)NULL;
|
||||
GdkFontPrivate *fontPrivate;
|
||||
XFontStruct *fontInfo;
|
||||
unsigned long pr = 0;
|
||||
|
||||
// XXX I am not sure if I can use this as it is supposed to
|
||||
// be private.
|
||||
fontPrivate = (GdkFontPrivate*) theFont;
|
||||
fontInfo = (XFontStruct *)GDK_FONT_XFONT( theFont );
|
||||
|
||||
::XGetFontProperty( fontInfo, XA_FULL_NAME, &pr );
|
||||
if( pr )
|
||||
{
|
||||
fontName = XGetAtomName( fontPrivate->xdisplay, pr );
|
||||
aFont->name.AssignWithConversion( fontName );
|
||||
::XFree( fontName );
|
||||
}
|
||||
|
||||
pr = 0;
|
||||
::XGetFontProperty( fontInfo, XA_WEIGHT, &pr );
|
||||
if ( pr > 10 )
|
||||
aFont->weight = NS_FONT_WEIGHT_BOLD;
|
||||
|
||||
pr = 0;
|
||||
Atom pixelSizeAtom = ::XInternAtom(gdk_display, "PIXEL_SIZE", 0);
|
||||
::XGetFontProperty( fontInfo, pixelSizeAtom, &pr );
|
||||
if( pr )
|
||||
aFont->size = NSIntPixelsToTwips(pr, mPixelsToTwips);
|
||||
|
||||
pr = 0;
|
||||
::XGetFontProperty( fontInfo, XA_ITALIC_ANGLE, &pr );
|
||||
if( pr )
|
||||
aFont->style = NS_FONT_STYLE_ITALIC;
|
||||
|
||||
pr = 0;
|
||||
::XGetFontProperty( fontInfo, XA_UNDERLINE_THICKNESS, &pr );
|
||||
if( pr )
|
||||
aFont->decorations = NS_FONT_DECORATION_UNDERLINE;
|
||||
|
||||
status = NS_OK;
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
104
mozilla/gfx/src/gtk/nsDeviceContextGTK.h
Normal file
104
mozilla/gfx/src/gtk/nsDeviceContextGTK.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
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 GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) 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;
|
||||
nsPaletteInfo mPaletteInfo;
|
||||
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, nsSystemAttrID anID, nsFont* aFont) const;
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextGTK_h___ */
|
||||
|
||||
82
mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp
Normal file
82
mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- 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) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#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()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryGTK, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryGTK)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryGTK)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* 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,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIDeviceContextSpec *devSpec = nsnull;
|
||||
|
||||
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
|
||||
|
||||
if (nsnull != devSpec){
|
||||
if (NS_OK == ((nsDeviceContextSpecGTK *)devSpec)->Init(aQuiet)){
|
||||
aNewSpec = devSpec;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
45
mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.h
Normal file
45
mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#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,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryGTK();
|
||||
};
|
||||
|
||||
#endif
|
||||
389
mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
Normal file
389
mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
Normal file
@@ -0,0 +1,389 @@
|
||||
/* -*- 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 "nsDeviceContextSpecG.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIAppShellComponentImpl.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsINetSupportDialogService.h"
|
||||
|
||||
static NS_DEFINE_IID( kAppShellServiceCID, NS_APPSHELL_SERVICE_CID );
|
||||
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
|
||||
|
||||
//#include "prmem.h"
|
||||
//#include "plstr.h"
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Construct the nsDeviceContextSpecGTK
|
||||
* @update dc 12/02/98
|
||||
*/
|
||||
nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Destroy the nsDeviceContextSpecGTK
|
||||
* @update dc 2/15/98
|
||||
*/
|
||||
nsDeviceContextSpecGTK :: ~nsDeviceContextSpecGTK()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
|
||||
#ifdef USE_XPRINT
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecXPIID, NS_IDEVICE_CONTEXT_SPEC_XP_IID);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecGTK, kDeviceContextSpecIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecGTK)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK :: 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;
|
||||
}
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
if (aIID.Equals(kIDeviceContextSpecXPIID))
|
||||
{
|
||||
*aInstancePtr = (void*) (nsIDeviceContextSpecXP*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
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(nsDeviceContextSpecGTK)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the nsDeviceContextSpecGTK
|
||||
* @update dc 2/15/98
|
||||
* @update syd 3/2/99
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
|
||||
|
||||
// if there is a current selection then enable the "Selection" radio button
|
||||
if (NS_SUCCEEDED(rv) && printService) {
|
||||
PRBool isOn;
|
||||
printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, &isOn);
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pPrefs) {
|
||||
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
|
||||
}
|
||||
}
|
||||
|
||||
char *path;
|
||||
PRBool reversed = PR_FALSE;
|
||||
PRBool color = PR_FALSE;
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt16 printRange = nsIPrintOptions::kRangeAllPages;
|
||||
PRInt32 paper_size = NS_LETTER_SIZE;
|
||||
PRInt32 fromPage = 1;
|
||||
PRInt32 toPage = 1;
|
||||
PRUnichar *command = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
double dleft = 0.5;
|
||||
double dright = 0.5;
|
||||
double dtop = 0.5;
|
||||
double dbottom = 0.5;
|
||||
|
||||
rv = NS_OK;
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kDialogParamBlockCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDialogParamBlock),
|
||||
getter_AddRefs(ioParamBlock));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> hiddenWindow;
|
||||
nsCOMPtr<nsIDOMWindowInternal> mWindow;
|
||||
|
||||
JSContext *jsContext;
|
||||
rv = appShell->GetHiddenWindowAndJSContext(getter_AddRefs(hiddenWindow), &jsContext);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
void *stackPtr;
|
||||
jsval *argv = JS_PushArguments(jsContext,
|
||||
&stackPtr,
|
||||
"sss%ip",
|
||||
"chrome://global/content/printdialog.xul",
|
||||
"_blank",
|
||||
"chrome,modal",
|
||||
(const nsIID *) (&NS_GET_IID(nsIDialogParamBlock)),
|
||||
(nsISupports *) ioParamBlock);
|
||||
if (argv) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> newWindow;
|
||||
|
||||
rv = hiddenWindow->OpenDialog(jsContext,
|
||||
argv,
|
||||
4,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
JS_PopArguments(jsContext, stackPtr);
|
||||
PRInt32 buttonPressed = 0;
|
||||
ioParamBlock->GetInt(0, &buttonPressed);
|
||||
if (buttonPressed == 0) {
|
||||
|
||||
if (printService) {
|
||||
printService->GetPrintReversed(&reversed);
|
||||
printService->GetPrintInColor(&color);
|
||||
printService->GetPaperSize(&paper_size);
|
||||
printService->GetPrintCommand(&command);
|
||||
printService->GetPrintRange(&printRange);
|
||||
printService->GetToFileName(&printfile);
|
||||
printService->GetPrintToFile(&tofile);
|
||||
printService->GetStartPageRange(&fromPage);
|
||||
printService->GetEndPageRange(&toPage);
|
||||
printService->GetMarginTop(&dtop);
|
||||
printService->GetMarginLeft(&dleft);
|
||||
printService->GetMarginBottom(&dbottom);
|
||||
printService->GetMarginRight(&dright);
|
||||
|
||||
if (command != nsnull && printfile != nsnull) {
|
||||
// convert Unicode strings to cstrings
|
||||
nsAutoString cmdStr;
|
||||
nsAutoString printFileStr;
|
||||
cmdStr = command;
|
||||
printFileStr = printfile;
|
||||
char * pCmdStr = cmdStr.ToNewCString();
|
||||
char * pPrintFileStr = printFileStr.ToNewCString();
|
||||
sprintf( mPrData.command, pCmdStr );
|
||||
sprintf( mPrData.path, pPrintFileStr);
|
||||
nsMemory::Free(pCmdStr);
|
||||
nsMemory::Free(pPrintFileStr);
|
||||
}
|
||||
|
||||
#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
|
||||
} else {
|
||||
#ifndef VMS
|
||||
sprintf( mPrData.command, "lpr" );
|
||||
#else
|
||||
// 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.
|
||||
sprintf( mPrData.command, "print" );
|
||||
#endif
|
||||
}
|
||||
|
||||
mPrData.top = dtop;
|
||||
mPrData.bottom = dbottom;
|
||||
mPrData.left = dleft;
|
||||
mPrData.right = dright;
|
||||
mPrData.fpf = !reversed;
|
||||
mPrData.grayscale = !color;
|
||||
mPrData.size = paper_size;
|
||||
mPrData.toPrinter = !tofile;
|
||||
|
||||
// PWD, HOME, or fail
|
||||
|
||||
if (!printfile) {
|
||||
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL )
|
||||
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL )
|
||||
strcpy( mPrData.path, "mozilla.ps" );
|
||||
if ( path != (char *) NULL )
|
||||
sprintf( mPrData.path, "%s/mozilla.ps", path );
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (command != nsnull) {
|
||||
nsMemory::Free(command);
|
||||
}
|
||||
if (printfile != nsnull) {
|
||||
nsMemory::Free(printfile);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetToPrinter( PRBool &aToPrinter )
|
||||
{
|
||||
aToPrinter = mPrData.toPrinter;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPrintMethod(int &aMethod )
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pPrefs) {
|
||||
PRInt32 method = 0;
|
||||
(void) pPrefs->GetIntPref("print.print_method", &method);
|
||||
aMethod = method;
|
||||
} else {
|
||||
aMethod = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Closes the printmanager if it is open.
|
||||
* @update dc 2/15/98
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK :: ClosePrintManager()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
112
mozilla/gfx/src/gtk/nsDeviceContextSpecG.h
Normal file
112
mozilla/gfx/src/gtk/nsDeviceContextSpecG.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsDeviceContextSpecG_h___
|
||||
#define nsDeviceContextSpecG_h___
|
||||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
#include "nsIDeviceContextSpecPS.h"
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
#include "nsIDeviceContextSpecXPrint.h"
|
||||
#endif
|
||||
#include "nsPrintdGTK.h"
|
||||
|
||||
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(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 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 GetUserCancelled( PRBool &aCancel );
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHOD GetPrintMethod(int &aMethod );
|
||||
#endif
|
||||
protected:
|
||||
/**
|
||||
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
virtual ~nsDeviceContextSpecGTK();
|
||||
|
||||
protected:
|
||||
|
||||
UnixPrData mPrData;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
295
mozilla/gfx/src/gtk/nsDrawingSurfaceGTK.cpp
Normal file
295
mozilla/gfx/src/gtk/nsDrawingSurfaceGTK.cpp
Normal file
@@ -0,0 +1,295 @@
|
||||
/* -*- 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 <gdk/gdkx.h>
|
||||
#include <gdk/gdkprivate.h>
|
||||
#include "nsDrawingSurfaceGTK.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsDrawingSurfaceGTK, nsIDrawingSurface, nsIDrawingSurfaceGTK)
|
||||
|
||||
//#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;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP 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;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP 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;
|
||||
}
|
||||
96
mozilla/gfx/src/gtk/nsDrawingSurfaceGTK.h
Normal file
96
mozilla/gfx/src/gtk/nsDrawingSurfaceGTK.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#ifndef nsDrawingSurfaceGTK_h___
|
||||
#define nsDrawingSurfaceGTK_h___
|
||||
|
||||
#include "nsIDrawingSurface.h"
|
||||
#include "nsIDrawingSurfaceGTK.h"
|
||||
|
||||
#include "nsTimer.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
class nsDrawingSurfaceGTK : public nsIDrawingSurface,
|
||||
public nsIDrawingSurfaceGTK
|
||||
{
|
||||
public:
|
||||
nsDrawingSurfaceGTK();
|
||||
virtual ~nsDrawingSurfaceGTK();
|
||||
|
||||
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);
|
||||
|
||||
//nsIDrawingSurfaceGTK interface
|
||||
|
||||
NS_IMETHOD Init(GdkDrawable *aDrawable, GdkGC *aGC);
|
||||
NS_IMETHOD Init(GdkGC *aGC, 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
|
||||
*/
|
||||
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
|
||||
3299
mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp
Normal file
3299
mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp
Normal file
File diff suppressed because it is too large
Load Diff
208
mozilla/gfx/src/gtk/nsFontMetricsGTK.h
Normal file
208
mozilla/gfx/src/gtk/nsFontMetricsGTK.h
Normal file
@@ -0,0 +1,208 @@
|
||||
/* -*- 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):
|
||||
*/
|
||||
|
||||
#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 <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 nsFontGTKUserDefined;
|
||||
class nsFontMetricsGTK;
|
||||
|
||||
class nsFontGTK
|
||||
{
|
||||
public:
|
||||
nsFontGTK();
|
||||
virtual ~nsFontGTK();
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
void LoadFont(void);
|
||||
|
||||
inline int SupportsChar(PRUnichar aChar)
|
||||
{ return mFont && FONT_HAS_GLYPH(mMap, aChar); };
|
||||
|
||||
virtual GdkFont* GetGDKFont(void);
|
||||
virtual PRBool GetGDKFontIs10646(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
|
||||
|
||||
PRUint32* mMap;
|
||||
nsFontCharSetInfo* mCharSetInfo;
|
||||
char* mName;
|
||||
nsFontGTKUserDefined* mUserDefinedFont;
|
||||
PRUint16 mSize;
|
||||
PRInt16 mBaselineAdjust;
|
||||
|
||||
protected:
|
||||
GdkFont* mFont;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
virtual nsresult GetSpaceWidth(nscoord &aSpaceWidth);
|
||||
|
||||
nsFontGTK* FindFont(PRUnichar aChar);
|
||||
nsFontGTK* FindUserDefinedFont(PRUnichar aChar);
|
||||
nsFontGTK* FindLocalFont(PRUnichar aChar);
|
||||
nsFontGTK* FindGenericFont(PRUnichar aChar);
|
||||
nsFontGTK* FindGlobalFont(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* PickASizeAndLoad(nsFontStretch* aStretch,
|
||||
nsFontCharSetInfo* aCharSet, PRUnichar aChar);
|
||||
|
||||
static nsresult FamilyExists(const nsString& aFontName);
|
||||
|
||||
//friend struct nsFontGTK;
|
||||
|
||||
nsFontGTK **mLoadedFonts;
|
||||
PRUint16 mLoadedFontsAlloc;
|
||||
PRUint16 mLoadedFontsCount;
|
||||
|
||||
nsFontGTK *mSubstituteFont;
|
||||
|
||||
nsCStringArray mFonts;
|
||||
PRUint16 mFontsIndex;
|
||||
nsVoidArray 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;
|
||||
};
|
||||
|
||||
class nsFontEnumeratorGTK : public nsIFontEnumerator
|
||||
{
|
||||
public:
|
||||
nsFontEnumeratorGTK();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFONTENUMERATOR
|
||||
};
|
||||
|
||||
#endif
|
||||
311
mozilla/gfx/src/gtk/nsGCCache.cpp
Normal file
311
mozilla/gfx/src/gtk/nsGCCache.cpp
Normal file
@@ -0,0 +1,311 @@
|
||||
/* -*- 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));)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
80
mozilla/gfx/src/gtk/nsGCCache.h
Normal file
80
mozilla/gfx/src/gtk/nsGCCache.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- 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();
|
||||
|
||||
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
|
||||
190
mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp
Normal file
190
mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
/* -*- 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 Christopher
|
||||
* Blizzard. Portions created by Christopher Blizzard are
|
||||
* Copyright (C) 2000 Christopher Blizzard. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "nsBlender.h"
|
||||
#include "nsFontMetricsGTK.h"
|
||||
#include "nsRenderingContextGTK.h"
|
||||
// aka nsDeviceContextSpecGTK.h
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
// aka nsDeviceContextSpecFactoryGTK.h
|
||||
#include "nsDeviceContextSpecFactoryG.h"
|
||||
#include "nsScreenManagerGtk.h"
|
||||
#include "nsScriptableRegion.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsDeviceContextGTK.h"
|
||||
#include "nsImageGTK.h"
|
||||
#include "nsPrintOptionsGTK.h"
|
||||
|
||||
// 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(nsScreenManagerGtk)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsGTK)
|
||||
|
||||
// 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);
|
||||
if (rgn != nsnull)
|
||||
{
|
||||
nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(rgn);
|
||||
inst = scriptableRgn;
|
||||
}
|
||||
if (!inst)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(inst);
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(inst);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult nsImageManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if ( !aResult )
|
||||
{
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = nsnull;
|
||||
if (aOuter)
|
||||
{
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
// this will return an image manager with a count of 1
|
||||
rv = NS_NewImageManager((nsIImageManager **)aResult);
|
||||
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 },
|
||||
{ "Image Manager",
|
||||
NS_IMAGEMANAGER_CID,
|
||||
// "@mozilla.org/gfx/image_manager;1",
|
||||
"@mozilla.org/gfx/imagemanager;1",
|
||||
nsImageManagerConstructor },
|
||||
{ "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 },
|
||||
{ "Gtk Screen Manager",
|
||||
NS_SCREENMANAGER_CID,
|
||||
// "@mozilla.org/gfx/screenmanager/gtk;1",
|
||||
"@mozilla.org/gfx/screenmanager;1",
|
||||
nsScreenManagerGtkConstructor }
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
nsGfxGTKModuleDtor(nsIModule *self)
|
||||
{
|
||||
nsRenderingContextGTK::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_DTOR("nsGfxGTKModule", components, nsGfxGTKModuleDtor)
|
||||
|
||||
125
mozilla/gfx/src/gtk/nsGraphicsStateGTK.cpp
Normal file
125
mozilla/gfx/src/gtk/nsGraphicsStateGTK.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
/* -*- 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 "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;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user