Back to index

lightning-sunbird  0.9+nobinonly
nsIRegion.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsIRegion_h___
00039 #define nsIRegion_h___
00040 
00041 #include "nscore.h"
00042 #include "nsISupports.h"
00043 #include "nsRect.h"
00044 
00045 enum nsRegionComplexity
00046 {
00047   eRegionComplexity_empty = 0,
00048   eRegionComplexity_rect = 1,
00049   eRegionComplexity_complex = 2
00050 };
00051 
00052 typedef struct
00053 {
00054   PRInt32   x;
00055   PRInt32   y;
00056   PRUint32  width;
00057   PRUint32  height;
00058 } nsRegionRect;
00059 
00060 typedef struct
00061 {
00062   PRUint32      mNumRects;    //number of actual rects in the mRects array
00063   PRUint32      mRectsLen;    //length, in rects, of the mRects array
00064   PRUint32      mArea;        //area of the covered portion of the region
00065   nsRegionRect  mRects[1];
00066 } nsRegionRectSet;
00067 
00068 // An implementation of a region primitive that can be used to
00069 // represent arbitrary pixel areas. Probably implemented on top
00070 // of the native region primitive. The assumption is that, at worst,
00071 // it is a rectangle list.
00072 
00073 #define NS_IREGION_IID   \
00074 { 0x8ef366e0, 0xee94, 0x11d1,    \
00075 { 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
00076 
00077 class nsIRegion : public nsISupports
00078 {
00079 public:
00080   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IREGION_IID)
00081 
00082   virtual nsresult Init(void) = 0;
00083 
00092   virtual void SetTo(const nsIRegion &aRegion) = 0;
00093 
00105   virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
00106 
00115   virtual void Intersect(const nsIRegion &aRegion) = 0;
00116 
00128   virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
00129 
00138   virtual void Union(const nsIRegion &aRegion) = 0;
00139 
00151   virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
00152 
00161   virtual void Subtract(const nsIRegion &aRegion) = 0;
00162 
00174   virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
00175   
00184   virtual PRBool IsEmpty(void) = 0;
00185 
00195   virtual PRBool IsEqual(const nsIRegion &aRegion) = 0;
00196 
00208   virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) = 0;
00209 
00218   virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset) = 0;
00219 
00228   virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
00229   
00241   NS_IMETHOD GetRects(nsRegionRectSet **aRects) = 0;
00242 
00250   NS_IMETHOD FreeRects(nsRegionRectSet *aRects) = 0;
00251 
00257   NS_IMETHOD GetNativeRegion(void *&aRegion) const = 0;
00258 
00265   NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const = 0;
00266 
00275   NS_IMETHOD GetNumRects(PRUint32 *aRects) const = 0;
00276 };
00277 
00278 #endif  // nsIRegion_h___