merging the base and image parts of gfx2 to HEAD, renaming nsMargin, nsPoint, nsRect to whatever2 to avoid header name conflicts with gfx

still need to resolve issue with gfx2's nsIImage wanting to use nsIDrawable, since there arn't any ifdefs in idl...


git-svn-id: svn://10.0.0.236/trunk@84506 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pavlov%netscape.com 2001-01-07 01:40:18 +00:00
parent 45f94ff07d
commit 9d3a8417c6
19 changed files with 1868 additions and 0 deletions

View File

@ -0,0 +1,130 @@
/* -*- 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 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):
* Stuart Parmenter <pavlov@netscape.com>
*/
/**
* gfx idl declarations to be used by all gfx interfaces.
* @file gfxtypes.idl
*/
#include "nsrootidl.idl"
/*! @verbatim */
/* see bug 57094 */
%{C++
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
#include "gfxcompat.h"
%}
/*! @endverbatim */
/**
* gfx_dimension should be used for widths and heights
* @var typedef float gfx_dimension
*/
typedef float gfx_dimension;
/**
* gfx_coord should be used for x and y coordinates
* @var typedef float gfx_coord
*/
typedef float gfx_coord;
/**
* typedef that should be used for angles
* @var typedef float gfx_angle
*/
typedef float gfx_angle;
/**
* A color is a 32 bit unsigned integer with
* four components: R, G, B and A.
*
* @var typedef unsigned long gfx_color
*/
typedef unsigned long gfx_color;
typedef gfx_color nscolor;
/**
* typedef that should be used for bit depths
* @var typedef unsigned short gfx_depth
*/
typedef unsigned short gfx_depth; // is short ok?
/**
* typedef that should be used for image formats
* @var typedef long gfx_format
* @see nsIGFXFormat
*/
typedef long gfx_format;
/**
* typedef that should be used for gamma levels
* @var typedef float gfx_gamma
*/
typedef float gfx_gamma;
/**
* nsIGFXFormat interface
*
* @author Tim Rowley <tor@cs.brown.edu>
* @author Stuart Parmenter <pavlov@netscape.com>
* @version 0.0
* @see gfx_format
*/
[scriptable]
interface nsIGFXFormat
{
/**
* RGB - duh...
*/
const gfx_format RGB = 0;
/**
* RGB_A1 - RGB image and 1-bit alpha mask
*/
const gfx_format RGB_A1 = 1;
/**
* RGB_A8 - RGB image and 8-bit alpha image
*/
const gfx_format RGB_A8 = 2;
/**
* RGBA - packed RGBA image
*/
const gfx_format RGBA = 3;
};
/*! @verbatim */
[ptr] native nsRect2(nsRect2);
[ptr] native nsSize2(nsSize2);
[ptr] native nsPoint2(nsPoint2);
%{C++
struct nsPoint2;
struct nsSize2;
struct nsRect2;
%}
/*! @endverbatim */

View File

@ -0,0 +1,35 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
/**
* gfx ifdef file to make gfx2 and gfx live together
* @file gfxcompat.h
*/
#ifdef GFX2_ONLY
typedef gfx_coord nscoord;
// add these later, work out the include deps, etc.
//typedef nsRect2 nsRect;
//typedef nsSize2 nsSize2;
#endif

View File

@ -0,0 +1,130 @@
/* -*- 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 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):
* Stuart Parmenter <pavlov@netscape.com>
*/
/**
* gfx idl declarations to be used by all gfx interfaces.
* @file gfxtypes.idl
*/
#include "nsrootidl.idl"
/*! @verbatim */
/* see bug 57094 */
%{C++
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
#include "gfxcompat.h"
%}
/*! @endverbatim */
/**
* gfx_dimension should be used for widths and heights
* @var typedef float gfx_dimension
*/
typedef float gfx_dimension;
/**
* gfx_coord should be used for x and y coordinates
* @var typedef float gfx_coord
*/
typedef float gfx_coord;
/**
* typedef that should be used for angles
* @var typedef float gfx_angle
*/
typedef float gfx_angle;
/**
* A color is a 32 bit unsigned integer with
* four components: R, G, B and A.
*
* @var typedef unsigned long gfx_color
*/
typedef unsigned long gfx_color;
typedef gfx_color nscolor;
/**
* typedef that should be used for bit depths
* @var typedef unsigned short gfx_depth
*/
typedef unsigned short gfx_depth; // is short ok?
/**
* typedef that should be used for image formats
* @var typedef long gfx_format
* @see nsIGFXFormat
*/
typedef long gfx_format;
/**
* typedef that should be used for gamma levels
* @var typedef float gfx_gamma
*/
typedef float gfx_gamma;
/**
* nsIGFXFormat interface
*
* @author Tim Rowley <tor@cs.brown.edu>
* @author Stuart Parmenter <pavlov@netscape.com>
* @version 0.0
* @see gfx_format
*/
[scriptable]
interface nsIGFXFormat
{
/**
* RGB - duh...
*/
const gfx_format RGB = 0;
/**
* RGB_A1 - RGB image and 1-bit alpha mask
*/
const gfx_format RGB_A1 = 1;
/**
* RGB_A8 - RGB image and 8-bit alpha image
*/
const gfx_format RGB_A8 = 2;
/**
* RGBA - packed RGBA image
*/
const gfx_format RGBA = 3;
};
/*! @verbatim */
[ptr] native nsRect2(nsRect2);
[ptr] native nsSize2(nsSize2);
[ptr] native nsPoint2(nsPoint2);
%{C++
struct nsPoint2;
struct nsSize2;
struct nsRect2;
%}
/*! @endverbatim */

37
mozilla/gfx2/Makefile.in Normal file
View File

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

View File

@ -0,0 +1,49 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Stuart Parmenter <pavlov@netscape.com>
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx2
XPIDL_MODULE = gfx2
XPIDLSRCS = \
gfxtypes.idl \
nsIImage.idl \
$(NULL)
EXPORTS = \
gfxcompat.h \
nsMargin2.h \
nsPoint2.h \
nsRect2.h \
nsSize2.h \
nsUnitConverters.h \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,35 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
/**
* gfx ifdef file to make gfx2 and gfx live together
* @file gfxcompat.h
*/
#ifdef GFX2_ONLY
typedef gfx_coord nscoord;
// add these later, work out the include deps, etc.
//typedef nsRect2 nsRect;
//typedef nsSize2 nsSize2;
#endif

View File

@ -0,0 +1,130 @@
/* -*- 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 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):
* Stuart Parmenter <pavlov@netscape.com>
*/
/**
* gfx idl declarations to be used by all gfx interfaces.
* @file gfxtypes.idl
*/
#include "nsrootidl.idl"
/*! @verbatim */
/* see bug 57094 */
%{C++
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
#include "gfxcompat.h"
%}
/*! @endverbatim */
/**
* gfx_dimension should be used for widths and heights
* @var typedef float gfx_dimension
*/
typedef float gfx_dimension;
/**
* gfx_coord should be used for x and y coordinates
* @var typedef float gfx_coord
*/
typedef float gfx_coord;
/**
* typedef that should be used for angles
* @var typedef float gfx_angle
*/
typedef float gfx_angle;
/**
* A color is a 32 bit unsigned integer with
* four components: R, G, B and A.
*
* @var typedef unsigned long gfx_color
*/
typedef unsigned long gfx_color;
typedef gfx_color nscolor;
/**
* typedef that should be used for bit depths
* @var typedef unsigned short gfx_depth
*/
typedef unsigned short gfx_depth; // is short ok?
/**
* typedef that should be used for image formats
* @var typedef long gfx_format
* @see nsIGFXFormat
*/
typedef long gfx_format;
/**
* typedef that should be used for gamma levels
* @var typedef float gfx_gamma
*/
typedef float gfx_gamma;
/**
* nsIGFXFormat interface
*
* @author Tim Rowley <tor@cs.brown.edu>
* @author Stuart Parmenter <pavlov@netscape.com>
* @version 0.0
* @see gfx_format
*/
[scriptable]
interface nsIGFXFormat
{
/**
* RGB - duh...
*/
const gfx_format RGB = 0;
/**
* RGB_A1 - RGB image and 1-bit alpha mask
*/
const gfx_format RGB_A1 = 1;
/**
* RGB_A8 - RGB image and 8-bit alpha image
*/
const gfx_format RGB_A8 = 2;
/**
* RGBA - packed RGBA image
*/
const gfx_format RGBA = 3;
};
/*! @verbatim */
[ptr] native nsRect2(nsRect2);
[ptr] native nsSize2(nsSize2);
[ptr] native nsPoint2(nsPoint2);
%{C++
struct nsPoint2;
struct nsSize2;
struct nsRect2;
%}
/*! @endverbatim */

View File

@ -0,0 +1,121 @@
/** -*- 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 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):
* Stuart Parmenter <pavlov@netscape.com>
*/
#include "nsISupports.idl"
#include "gfxtypes.idl"
interface nsIDrawable;
/**
* nsIImage interface
*
* @author Tim Rowley <tor@cs.brown.edu>
* @author Stuart Parmenter <pavlov@netscape.com>
* @version 1.1
* @see "gfx2"
*/
[scriptable, uuid(5e8405a4-1dd2-11b2-8385-bc8e3446cad3)]
interface nsIImage : nsISupports
{
/**
* Create a new aWidth x aHeight sized image.
*
* @param aWidth The width of the image to create.
* @param aHeight The height of the image to create.
* @param aFormat the width of the image to create.
*
* @note The data of a new image is unspecified (Whats the word i'm looking for here?).
*/
void init(in gfx_dimension aWidth,
in gfx_dimension aHeight,
in gfx_format aFormat);
/**
* Create an image with the bits copied from aDrawable
*
* @param aDrawable The drawing area to gather the image bits from.
* @param aX The x-coordinate of the rectangle in aDrawable to grab.
* @param aY The y-coordinate of the rectangle in aDrawable to grab.
* @param aWidth The width of the rectangle in aDrawable to grab.
* @param aHeight The height of the rectangle in aDrawable to grab.
*/
void initFromDrawable(in nsIDrawable aDrawable,
in gfx_coord aX,
in gfx_coord aY,
in gfx_dimension aWidth,
in gfx_dimension aHeight);
/* we should be consistent about using x, y, width, height and x1,x2, etc */
void setDecodedRect(in gfx_coord x1,
in gfx_coord y1,
in gfx_coord x2,
in gfx_coord y2);
readonly attribute gfx_coord decodedX1;
readonly attribute gfx_coord decodedY1;
readonly attribute gfx_coord decodedX2;
readonly attribute gfx_coord decodedY2;
/**
* A packed representation of the image data as specified by format.
*/
readonly attribute PRUint8 bits;
/**
* The width of the image.
*/
readonly attribute gfx_dimension width;
/**
* The height of the image.
*/
readonly attribute gfx_dimension height;
/**
* The image data format the image was created with.
* @see nsIGFXFormat
*/
readonly attribute gfx_format format;
readonly attribute long lineStride;
/* alpha stuff */
/* depending on the platform and we may not need abits (some might prefer */
/* a packed representation of rgba data */
readonly attribute PRUint8 abits;
readonly attribute long aLineStride;
/**
* Does the system want to top to bottom row ordering.
* @note this should probably be on nsIOutputDevice if we want it.
* @note urgh... you want image decoders to obey this? (tor)
*/
readonly attribute boolean isRowOrderTopToBottom;
/**
* Used to let the implimentation know that the image data has changed.
* @note need to specify some flags... (or if all data is packed in to 1 accessor, remove flags)
*/
[noscript] void setImageUpdated(in long aFlags, [const] in nsRect2 updateRect);
};

View File

@ -0,0 +1,85 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-2000 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
#ifndef NSMARGIN_H
#define NSMARGIN_H
#include "gfxtypes.h"
struct nsMargin2 {
gfx_coord left, top, right, bottom;
// Constructors
nsMargin2() {}
nsMargin2(const nsMargin2& aMargin) {*this = aMargin;}
nsMargin2(gfx_coord aLeft, gfx_coord aTop, gfx_coord aRight, gfx_coord aBottom) {
left = aLeft; top = aTop;
right = aRight; bottom = aBottom;
}
void SizeTo(gfx_coord aLeft, gfx_coord aTop,
gfx_coord aRight, gfx_coord aBottom) {
left = aLeft; top = aTop;
right = aRight; bottom = aBottom;
}
void SizeBy(gfx_coord aLeft, gfx_coord aTop,
gfx_coord aRight, gfx_coord 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 nsMargin2& aMargin) const {
return (PRBool) ((left == aMargin.left) && (top == aMargin.top) &&
(right == aMargin.right) && (bottom == aMargin.bottom));
}
PRBool operator!=(const nsMargin2& aMargin) const {
return (PRBool) ((left != aMargin.left) || (top != aMargin.top) ||
(right != aMargin.right) || (bottom != aMargin.bottom));
}
nsMargin2 operator+(const nsMargin2& aMargin) const {
return nsMargin2(left + aMargin.left, top + aMargin.top,
right + aMargin.right, bottom + aMargin.bottom);
}
nsMargin2 operator-(const nsMargin2& aMargin) const {
return nsMargin2(left - aMargin.left, top - aMargin.top,
right - aMargin.right, bottom - aMargin.bottom);
}
nsMargin2& operator+=(const nsMargin2& aMargin) {
left += aMargin.left;
top += aMargin.top;
right += aMargin.right;
bottom += aMargin.bottom;
return *this;
}
nsMargin2& operator-=(const nsMargin2& aMargin) {
left -= aMargin.left;
top -= aMargin.top;
right -= aMargin.right;
bottom -= aMargin.bottom;
return *this;
}
};
#endif /* NSMARGIN_H */

View File

@ -0,0 +1,103 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-2000 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
#ifndef NSPOINT_H
#define NSPOINT_H
#include "gfxtypes.h"
/**
* nsPoint2
*
* @version 1.1
**/
struct nsPoint2 {
gfx_coord x, y;
// Constructors
nsPoint2() {}
nsPoint2(const nsPoint2& aPoint) {x = aPoint.x; y = aPoint.y;}
nsPoint2(gfx_coord aX, gfx_coord aY) {x = aX; y = aY;}
void MoveTo(gfx_coord aX, gfx_coord aY) {x = aX; y = aY;}
void MoveBy(gfx_coord aDx, gfx_coord 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 nsPoint2& aPoint) const {
return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
}
PRBool operator!=(const nsPoint2& aPoint) const {
return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
}
nsPoint2 operator+(const nsPoint2& aPoint) const {
return nsPoint2(x + aPoint.x, y + aPoint.y);
}
nsPoint2 operator-(const nsPoint2& aPoint) const {
return nsPoint2(x - aPoint.x, y - aPoint.y);
}
nsPoint2& operator+=(const nsPoint2& aPoint) {
x += aPoint.x;
y += aPoint.y;
return *this;
}
nsPoint2& operator-=(const nsPoint2& 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
*
* @author Don Cone <dcone@netscape.com> (3/29/00)
* @version 0.0
*/
struct nsPathPoint: public nsPoint2{
PRBool mIsOnCurve;
// Constructors
nsPathPoint() {}
nsPathPoint(const nsPathPoint& aPoint) {
x = aPoint.x;
y = aPoint.y;
mIsOnCurve = aPoint.mIsOnCurve;
}
nsPathPoint(gfx_coord aX, gfx_coord aY) {
x = aX;
y = aY;
mIsOnCurve = PR_TRUE;
}
nsPathPoint(gfx_coord aX, gfx_coord aY, PRBool aIsOnCurve) {
x = aX;
y = aY;
mIsOnCurve = aIsOnCurve;
}
};
#endif /* NSPOINT_H */

View File

@ -0,0 +1,219 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-2000 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
#ifndef NSRECT_H
#define NSRECT_H
#include <stdio.h>
#include "gfxtypes.h"
#include "nsPoint2.h"
#include "nsSize2.h"
#include "nsUnitConverters.h"
struct nsMargin2;
/**
* nsRect2
*
* @version 1.1
**/
struct nsRect2 {
gfx_coord x, y;
gfx_dimension width, height;
// Constructors
nsRect2() : x(0), y(0), width(0), height(0) {}
nsRect2(const nsRect2& aRect) {
*this = aRect;
}
nsRect2(const nsPoint2& aOrigin, const nsSize2 &aSize) {
x = aOrigin.x; y = aOrigin.y;
width = aSize.width; height = aSize.height;
}
nsRect2(gfx_coord aX, gfx_coord aY, gfx_dimension aWidth, gfx_dimension 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;}
/**
* Contains \a aRect
* @overload
*
* @param aRect
* @return TRUE if \a aRect is contained inside of 'this'.
*/
PRBool Contains(const nsRect2& aRect) const;
/**
* Contains the point (\a aX, \a aY)
* @overload
*
* @param aX
* @param aY
* @return TRUE if (\a aX, \a aY) is contained inside of 'this'.
*/
PRBool Contains(gfx_coord aX, gfx_coord aY) const;
/**
* Contains the point \a aPoint
* @overload
*
* @param aPoint
* @return TRUE if \a aPoint is contained inside of 'this'.
*/
PRBool Contains(const nsPoint2& aPoint) const {
return Contains(aPoint.x, aPoint.y);
}
/**
* Intersect 'this' and \a aRect
* @param aRect The rectangle to intersect 'this' with.
* @return TRUE if the receiver overlaps \a aRect and FALSE otherwise.
*/
PRBool Intersects(const nsRect2& aRect) const;
/**
* Computes the area in which \a aRect1 and \a aRect2 overlap, and fills 'this' with
* the result.
*
* @param aRect1
* @param aRect2
*
* @return FALSE if the rectangles don't intersect, and sets 'this'
* rect to be an empty rect.
*
* @note 'this' can be the same object as either \a aRect1 or \a aRect2
*/
PRBool IntersectRect(const nsRect2& aRect1, const nsRect2& aRect2);
/**
* Computes the smallest rectangle that contains both \a aRect1 and \a aRect2 and
* fills 'this' with the result.
*
* @param aRect1
* @param aRect2
*
* @return FALSE and sets 'this' rect to be an empty rect if both
* \a aRect1 and \a aRect2 are empty
*
* @note 'this' can be the same object as either aRect1 or aRect2
*/
PRBool UnionRect(const nsRect2& aRect1, const nsRect2& aRect2);
// Accessors
void SetRect(gfx_coord aX, gfx_coord aY, gfx_dimension aWidth, gfx_dimension aHeight) {
x = aX; y = aY; width = aWidth; height = aHeight;
}
void MoveTo(gfx_coord aX, gfx_coord aY) {
x = aX; y = aY;
}
void MoveTo(const nsPoint2& aPoint) {
x = aPoint.x; y = aPoint.y;
}
void MoveBy(gfx_coord aDx, gfx_coord aDy) {
x += aDx; y += aDy;
}
void SizeTo(gfx_dimension aWidth, gfx_dimension aHeight) {
width = aWidth; height = aHeight;
}
void SizeTo(const nsSize2& aSize) {
SizeTo(aSize.width, aSize.height);
}
void SizeBy(gfx_coord aDeltaWidth, gfx_coord aDeltaHeight) {
width += aDeltaWidth;
height += aDeltaHeight;
}
// Inflate the rect by the specified width/height or margin
void Inflate(gfx_coord aDx, gfx_coord aDy);
void Inflate(const nsSize2& aSize) {
Inflate(aSize.width, aSize.height);
}
void Inflate(const nsMargin2& aMargin);
// Deflate the rect by the specified width/height or margin
void Deflate(gfx_coord aDx, gfx_coord aDy);
void Deflate(const nsSize2& aSize) {
Deflate(aSize.width, aSize.height);
}
void Deflate(const nsMargin2& aMargin);
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator.
PRBool operator==(const nsRect2& aRect) const {
return (PRBool) ((IsEmpty() && aRect.IsEmpty()) ||
((x == aRect.x) && (y == aRect.y) &&
(width == aRect.width) && (height == aRect.height)));
}
PRBool operator!=(const nsRect2& aRect) const {
return (PRBool) !operator==(aRect);
}
nsRect2 operator+(const nsRect2& aRect) const {
return nsRect2(x + aRect.x, y + aRect.y,
width + aRect.width, height + aRect.height);
}
nsRect2 operator-(const nsRect2& aRect) const {
return nsRect2(x - aRect.x, y - aRect.y,
width - aRect.width, height - aRect.height);
}
nsRect2& operator+=(const nsPoint2& aPoint) {
x += aPoint.x; y += aPoint.y; return *this;
}
nsRect2& operator-=(const nsPoint2& aPoint) {
x -= aPoint.x; y -= aPoint.y; return *this;
}
nsRect2& operator*=(const float aScale) {
x = x * aScale;
y = y * aScale;
width = width * aScale;
height = height * aScale;
return *this;
}
nsRect2& ScaleRoundOut(const float aScale);
nsRect2& ScaleRoundIn(const float aScale);
// Helper methods for computing the extents
gfx_coord XMost() const {
return x + width;
}
gfx_coord YMost() const {
return y + height;
}
};
#ifdef DEBUG_RECT
// Diagnostics
extern NS_GFX FILE* operator<<(FILE* out, const nsRect2& rect);
#endif
#endif /* NSRECT_H */

View File

@ -0,0 +1,74 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-2000 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
#ifndef NSSIZE_H
#define NSSIZE_H
#include "gfxtypes.h"
// Maximum allowable size
#define NS_MAXSIZE nscoord(1 << 30)
/**
* nsSize2
*
* @version 0.0
**/
struct nsSize2 {
gfx_dimension width;
gfx_dimension height;
// Constructors
nsSize2() {}
nsSize2(const nsSize2& aSize) {width = aSize.width; height = aSize.height;}
nsSize2(gfx_dimension aWidth, gfx_dimension aHeight) {width = aWidth; height = aHeight;}
void SizeTo(gfx_dimension aWidth, gfx_dimension aHeight) {width = aWidth; height = aHeight;}
void SizeBy(gfx_dimension aDeltaWidth, gfx_dimension 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 nsSize2& aSize) const {
return (PRBool) ((width == aSize.width) && (height == aSize.height));
}
PRBool operator!=(const nsSize2& aSize) const {
return (PRBool) ((width != aSize.width) || (height != aSize.height));
}
nsSize2 operator+(const nsSize2& aSize) const {
return nsSize2(width + aSize.width, height + aSize.height);
}
nsSize2 operator-(const nsSize2& aSize) const {
return nsSize2(width - aSize.width, height - aSize.height);
}
nsSize2& operator+=(const nsSize2& aSize) {width += aSize.width;
height += aSize.height;
return *this;}
nsSize2& operator-=(const nsSize2& aSize) {width -= aSize.width;
height -= aSize.height;
return *this;}
};
#endif /* NSSIZE_H */

View File

@ -0,0 +1,188 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-2000 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*/
#ifndef nsUnitConverters_h__
#define nsUnitConverters_h__
#include "gfxtypes.h"
#include <math.h>
/**
* gfx unit conversion functions
* @file nsUnitConverters.h
*/
/**
* Unit Convertion Constants
* @defgroup conversion_constants Unit conversion constants
*/
/**
* ROUND_EXCLUSIVE_CONST_FLOAT
* @ingroup conversion_constants
* @note XXX this should be derived from platform FLOAT_MIN
*/
#define ROUND_EXCLUSIVE_CONST_FLOAT 0.4999999999999999
/**
* ROUND_CONST_FLOAT
* @ingroup conversion_constants
*/
#define ROUND_CONST_FLOAT 0.5
/**
* CEIL_CONST_FLOAT
* @ingroup conversion_constants
* @note XXX this should be derived from platform FLOAT_MIN
*/
#define CEIL_CONST_FLOAT 0.9999999999999999
/**
* gfx_coord rounding, floor, ceil functions
* @defgroup gfx_coord_functions gfx_coord conversion functions
*/
/**
* Return the absolute value of \a aValue
* @ingroup gfx_coord_functions
* @param aValue the value you wish to get the absolute value of
* @return the absolute value
*/
inline gfx_coord GFXCoordAbs(gfx_coord aValue)
{
return fabs(aValue);
}
/**
* Round a gfx_coord
* @ingroup gfx_coord_functions
* @param aValue the value you wish to round
* @return the rounded value
*/
inline gfx_coord GFXCoordRound(gfx_coord aValue)
{
return (0.0f <= aValue) ? (aValue + ROUND_CONST_FLOAT) : (aValue - ROUND_CONST_FLOAT);
}
/**
* Floor a gfx_coord
* @ingroup gfx_coord_functions
* @param aValue the value you wish to floor
* @return the floored value
*/
inline gfx_coord GFXCoordFloor(gfx_coord aValue)
{
return (0.0f <= aValue) ? aValue : (aValue - CEIL_CONST_FLOAT);
}
/**
* Ceil a gfx_coord
* @ingroup gfx_coord_functions
* @param aValue the value you wish to ceil
* @return the ceiled value
*/
inline gfx_coord GFXCoordCeil(gfx_coord aValue)
{
return (0.0f <= aValue) ? (aValue + CEIL_CONST_FLOAT) : aValue;
}
/**
* gfx_coord -> integer
* @defgroup gfx_coord_to_int_functions gfx_coord to integer conversion functions
*/
/**
* Round a gfx_coord to a 32bit integer
* @ingroup gfx_coord_to_int_functions
* @param aValue the value you wish to round
* @return the rounded integer value
*/
inline PRInt32 GFXCoordToIntRound(gfx_coord aValue)
{
return (0.0f <= aValue) ? PRInt32(aValue + ROUND_CONST_FLOAT) : PRInt32(aValue - ROUND_CONST_FLOAT);
}
/**
* Floor a gfx_coord and convert to a 32bit integer
* @ingroup gfx_coord_to_int_functions
* @param aValue the value you wish to floor
* @return the floored 32bit integer value
*/
inline PRInt32 GFXCoordToIntFloor(gfx_coord aValue)
{
return (0.0f <= aValue) ? PRInt32(aValue) : PRInt32(aValue - CEIL_CONST_FLOAT);
}
/**
* Ceil a gfx_coord and convert to a 32bit integer
* @ingroup gfx_coord_to_int_functions
* @param aValue the value you wish to ceil
* @return the ceiled 32bit integer value
*/
inline PRInt32 GFXCoordToIntCeil(gfx_coord aValue)
{
return (0.0f <= aValue) ? PRInt32(aValue + CEIL_CONST_FLOAT) : PRInt32(aValue);
}
/**
* gfx_angle -> integer
* @defgroup gfx_angle_to_int_functions gfx_angle to integer conversion functions
*/
/**
* Round a gfx_angle to a 32bit integer
* @ingroup gfx_angle_to_int_functions
* @param aValue the value you wish to round
* @return the rounded integer value
*/
inline PRInt32 GFXAngleToIntRound(gfx_angle aValue)
{
return (0.0f <= aValue) ? PRInt32(aValue + ROUND_CONST_FLOAT) : PRInt32(aValue - ROUND_CONST_FLOAT);
}
/**
* other... ?
*/
#if 0
inline gfx_coord NSToCoordRoundExclusive(float aValue)
{
return ((0.0f <= aValue) ? nscoord(aValue + ROUND_EXCLUSIVE_CONST_FLOAT) :
nscoord(aValue - ROUND_EXCLUSIVE_CONST_FLOAT));
}
inline PRInt32 NSToIntRoundExclusive(float aValue)
{
return ((0.0f <= aValue) ? PRInt32(aValue + ROUND_EXCLUSIVE_CONST_FLOAT) :
PRInt32(aValue - ROUND_EXCLUSIVE_CONST_FLOAT));
}
#endif
#endif

View File

@ -0,0 +1,44 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Stuart Parmenter <pavlov@netscape.com>
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx2
LIBRARY_NAME = gfx_base
CPPSRCS = \
nsRect.cpp \
$(NULL)
DIRS = xlib
# we don't want the shared lib, but we want to force the creation of a static lib.
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,48 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Stuart Parmenter <pavlov@netscape.com>
#
DEPTH = ..\..
include <$(DEPTH)/config/config.mak>
MODULE = gfx2
LIBRARY_NAME= gfx_base
DLLNAME = gfx_base
OBJS = \
.\$(OBJDIR)\nsRect.obj \
$(NULL)
MAKE_OBJ_TYPE = DLL
DLL=.\$(OBJDIR)\$(DLLNAME).dll
DIRS = windows
include <$(DEPTH)\config\rules.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
rm -f $(PDBFILE).pdb

213
mozilla/gfx2/src/nsRect.cpp Normal file
View File

@ -0,0 +1,213 @@
/* -*- 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 "nsRect2.h"
#include "nsMargin2.h"
#ifdef DEBUG_STRING
#include "nsString.h"
#endif
#ifdef MIN
#undef MIN
#endif
#ifdef MAX
#undef MAX
#endif
#define MIN(a,b)\
((a) < (b) ? (a) : (b))
#define MAX(a,b)\
((a) > (b) ? (a) : (b))
// Containment
PRBool nsRect2::Contains(gfx_coord aX, gfx_coord aY) const
{
return (PRBool) ((aX >= x) && (aY >= y) &&
(aX < XMost()) && (aY < YMost()));
}
PRBool nsRect2::Contains(const nsRect2 &aRect) const
{
return (PRBool) ((aRect.x >= x) && (aRect.y >= y) &&
(aRect.XMost() <= XMost()) && (aRect.YMost() <= YMost()));
}
// Intersection. Returns TRUE if the receiver overlaps aRect and
// FALSE otherwise
PRBool nsRect2::Intersects(const nsRect2 &aRect) const
{
return (PRBool) ((x < aRect.XMost()) && (y < aRect.YMost()) &&
(aRect.x < XMost()) && (aRect.y < YMost()));
}
// Computes the area in which aRect1 and aRect2 overlap and fills 'this' with
// the result. Returns FALSE if the rectangles don't intersect.
PRBool nsRect2::IntersectRect(const nsRect2 &aRect1, const nsRect2 &aRect2)
{
gfx_coord xmost1 = aRect1.XMost();
gfx_coord ymost1 = aRect1.YMost();
gfx_coord xmost2 = aRect2.XMost();
gfx_coord ymost2 = aRect2.YMost();
gfx_coord temp;
x = MAX(aRect1.x, aRect2.x);
y = MAX(aRect1.y, aRect2.y);
// Compute the destination width
temp = MIN(xmost1, xmost2);
if (temp <= x) {
Empty();
return PR_FALSE;
}
width = temp - x;
// Compute the destination height
temp = MIN(ymost1, ymost2);
if (temp <= y) {
Empty();
return PR_FALSE;
}
height = temp - y;
return PR_TRUE;
}
// Computes the smallest rectangle that contains both aRect1 and aRect2 and
// fills 'this' with the result. Returns FALSE if both aRect1 and aRect2 are
// empty and TRUE otherwise
PRBool nsRect2::UnionRect(const nsRect2 &aRect1, const nsRect2 &aRect2)
{
PRBool result = PR_TRUE;
// Is aRect1 empty?
if (aRect1.IsEmpty()) {
if (aRect2.IsEmpty()) {
// Both rectangles are empty which is an error
Empty();
result = PR_FALSE;
} else {
// aRect1 is empty so set the result to aRect2
*this = aRect2;
}
} else if (aRect2.IsEmpty()) {
// aRect2 is empty so set the result to aRect1
*this = aRect1;
} else {
gfx_coord xmost1 = aRect1.XMost();
gfx_coord xmost2 = aRect2.XMost();
gfx_coord ymost1 = aRect1.YMost();
gfx_coord ymost2 = aRect2.YMost();
// Compute the origin
x = MIN(aRect1.x, aRect2.x);
y = MIN(aRect1.y, aRect2.y);
// Compute the size
width = MAX(xmost1, xmost2) - x;
height = MAX(ymost1, ymost2) - y;
}
return result;
}
// Inflate the rect by the specified width and height
void nsRect2::Inflate(gfx_coord aDx, gfx_coord aDy)
{
x -= aDx;
y -= aDy;
width += 2 * aDx;
height += 2 * aDy;
}
// Inflate the rect by the specified margin
void nsRect2::Inflate(const nsMargin2 &aMargin)
{
x -= aMargin.left;
y -= aMargin.top;
width += aMargin.left + aMargin.right;
height += aMargin.top + aMargin.bottom;
}
// Deflate the rect by the specified width and height
void nsRect2::Deflate(gfx_coord aDx, gfx_coord aDy)
{
x += aDx;
y += aDy;
width -= 2 * aDx;
height -= 2 * aDy;
}
// Deflate the rect by the specified margin
void nsRect2::Deflate(const nsMargin2 &aMargin)
{
x += aMargin.left;
y += aMargin.top;
width -= aMargin.left + aMargin.right;
height -= aMargin.top + aMargin.bottom;
}
// scale the rect but round to smallest containing rect
nsRect2& nsRect2::ScaleRoundOut(const float aScale)
{
gfx_coord right = GFXCoordCeil((x + width) * aScale);
gfx_coord bottom = GFXCoordCeil((y + height) * aScale);
x = GFXCoordFloor(x * aScale);
y = GFXCoordFloor(y * aScale);
width = (right - x);
height = (bottom - y);
return *this;
}
// scale the rect but round to largest contained rect
nsRect2& nsRect2::ScaleRoundIn(const float aScale)
{
gfx_coord right = GFXCoordFloor((x + width) * aScale);
gfx_coord bottom = GFXCoordFloor((y + height) * aScale);
x = GFXCoordCeil(x * aScale);
y = GFXCoordCeil(y * aScale);
width = (right - x);
height = (bottom - y);
return *this;
}
// Diagnostics
#ifdef DEBUG_RECT
FILE* operator<<(FILE* out, const nsRect2& rect)
{
nsAutoString tmp;
// Output the coordinates in fractional points so they're easier to read
tmp.AppendWithConversion("{");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.x));
tmp.AppendWithConversion(", ");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.y));
tmp.AppendWithConversion(", ");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.width));
tmp.AppendWithConversion(", ");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.height));
tmp.AppendWithConversion("}");
fputs(tmp, out);
return out;
}
#endif

View File

@ -0,0 +1,54 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Stuart Parmenter <pavlov@netscape.com>
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx2
LIBRARY_NAME = gfx2
IS_COMPONENT = 1
CPPSRCS = \
nsImage.cpp \
$(NULL)
SHARED_LIBRARY_LIBS = $(DIST)/lib/libgfx_base.a
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += -L$(DIST)/bin
EXTRA_DSO_LDOPTS += $(TK_LIBS)
CXXFLAGS += $(TK_CFLAGS)
EXTRA_DSO_LDOPTS += \
$(NSPR_LIBS) \
-lxpcom \
$(NULL)
ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif

View File

@ -0,0 +1,133 @@
/* -*- 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 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):
* Stuart Parmenter <pavlov@netscape.com>
*/
#include "nsImage.h"
NS_IMPL_ISUPPORTS1(nsImage, nsIImage)
nsImage::nsImage()
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
}
nsImage::~nsImage()
{
/* destructor code */
}
/* void init (in gfx_dimension aWidth, in gfx_dimension aHeight, in gfx_format aFormat); */
NS_IMETHODIMP nsImage::Init(gfx_dimension aWidth, gfx_dimension aHeight, gfx_format aFormat)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void initFromDrawable (in nsIDrawable aDrawable, in gfx_coord aX, in gfx_coord aY, in gfx_dimension aWidth, in gfx_dimension aHeight); */
NS_IMETHODIMP nsImage::InitFromDrawable(nsIDrawable *aDrawable, gfx_coord aX, gfx_coord aY, gfx_dimension aWidth, gfx_dimension aHeight)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setDecodedRect (in gfx_coord x1, in gfx_coord y1, in gfx_coord x2, in gfx_coord y2); */
NS_IMETHODIMP nsImage::SetDecodedRect(gfx_coord x1, gfx_coord y1, gfx_coord x2, gfx_coord y2)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute gfx_coord decodedX1; */
NS_IMETHODIMP nsImage::GetDecodedX1(gfx_coord *aDecodedX1)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute gfx_coord decodedY1; */
NS_IMETHODIMP nsImage::GetDecodedY1(gfx_coord *aDecodedY1)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute gfx_coord decodedX2; */
NS_IMETHODIMP nsImage::GetDecodedX2(gfx_coord *aDecodedX2)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute gfx_coord decodedY2; */
NS_IMETHODIMP nsImage::GetDecodedY2(gfx_coord *aDecodedY2)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute PRUint8 bits; */
NS_IMETHODIMP nsImage::GetBits(PRUint8 *aBits)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute gfx_dimension width; */
NS_IMETHODIMP nsImage::GetWidth(gfx_dimension *aWidth)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute gfx_dimension height; */
NS_IMETHODIMP nsImage::GetHeight(gfx_dimension *aHeight)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute gfx_format format; */
NS_IMETHODIMP nsImage::GetFormat(gfx_format *aFormat)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute long lineStride; */
NS_IMETHODIMP nsImage::GetLineStride(PRInt32 *aLineStride)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute PRUint8 abits; */
NS_IMETHODIMP nsImage::GetAbits(PRUint8 *aAbits)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute long aLineStride; */
NS_IMETHODIMP nsImage::GetALineStride(PRInt32 *aALineStride)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean isRowOrderTopToBottom; */
NS_IMETHODIMP nsImage::GetIsRowOrderTopToBottom(PRBool *aIsRowOrderTopToBottom)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* [noscript] void setImageUpdated (in long aFlags, [const] in nsRect2 updateRect); */
NS_IMETHODIMP nsImage::SetImageUpdated(PRInt32 aFlags, const nsRect2 * updateRect)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -0,0 +1,40 @@
/* -*- 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 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):
* Stuart Parmenter <pavlov@netscape.com>
*/
#include "nsIImage.h"
#define NS_IMAGE_CID \
{0x73c72e6c, 0x1dd2, 0x11b2, \
{ 0x98, 0xb7, 0xae, 0x59, 0x35, 0xee, 0x63, 0xf5 }}
class nsImage : public nsIImage
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIIMAGE
nsImage();
virtual ~nsImage();
/* additional members */
};