Back to index

lightning-sunbird  0.9+nobinonly
nsScriptableRegion.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla Communicator.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corp.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Patrick Beard
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #include "nsScriptableRegion.h"
00041 #include "nsIRegion.h"
00042 #include "nsCOMPtr.h"
00043 
00044 nsScriptableRegion::nsScriptableRegion(nsIRegion* region) : mRegion(nsnull)
00045 {
00046        mRegion = region;
00047        NS_IF_ADDREF(mRegion);
00048 }
00049 
00050 nsScriptableRegion::~nsScriptableRegion()
00051 {
00052        NS_IF_RELEASE(mRegion);
00053 }
00054 
00055 NS_IMPL_ISUPPORTS1(nsScriptableRegion, nsIScriptableRegion)
00056 
00057 NS_IMETHODIMP nsScriptableRegion::Init()
00058 {
00059        return mRegion->Init();
00060 }
00061 
00062 NS_IMETHODIMP nsScriptableRegion::SetToRegion(nsIScriptableRegion *aRegion)
00063 {
00064        nsCOMPtr<nsIRegion> region(do_QueryInterface(aRegion));
00065        mRegion->SetTo(*region);
00066        return NS_OK;
00067 }
00068 
00069 NS_IMETHODIMP nsScriptableRegion::SetToRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
00070 {
00071        mRegion->SetTo(aX, aY, aWidth, aHeight);
00072        return NS_OK;
00073 }
00074 
00075 NS_IMETHODIMP nsScriptableRegion::IntersectRegion(nsIScriptableRegion *aRegion)
00076 {
00077        nsCOMPtr<nsIRegion> region(do_QueryInterface(aRegion));
00078        mRegion->Intersect(*region);
00079        return NS_OK;
00080 }
00081 
00082 NS_IMETHODIMP nsScriptableRegion::IntersectRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
00083 {
00084        mRegion->Intersect(aX, aY, aWidth, aHeight);
00085        return NS_OK;
00086 }
00087 
00088 NS_IMETHODIMP nsScriptableRegion::UnionRegion(nsIScriptableRegion *aRegion)
00089 {
00090        nsCOMPtr<nsIRegion> region(do_QueryInterface(aRegion));
00091        mRegion->Union(*region);
00092        return NS_OK;
00093 }
00094 
00095 NS_IMETHODIMP nsScriptableRegion::UnionRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
00096 {
00097        mRegion->Union(aX, aY, aWidth, aHeight);
00098        return NS_OK;
00099 }
00100 
00101 NS_IMETHODIMP nsScriptableRegion::SubtractRegion(nsIScriptableRegion *aRegion)
00102 {
00103        nsCOMPtr<nsIRegion> region(do_QueryInterface(aRegion));
00104        mRegion->Subtract(*region);
00105        return NS_OK;
00106 }
00107 
00108 NS_IMETHODIMP nsScriptableRegion::SubtractRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
00109 {
00110        mRegion->Subtract(aX, aY, aWidth, aHeight);
00111        return NS_OK;
00112 }
00113 
00114 NS_IMETHODIMP nsScriptableRegion::IsEmpty(PRBool *isEmpty)
00115 {
00116        *isEmpty = mRegion->IsEmpty();
00117        return NS_OK;
00118 }
00119 
00120 NS_IMETHODIMP nsScriptableRegion::IsEqualRegion(nsIScriptableRegion *aRegion, PRBool *isEqual)
00121 {
00122        nsCOMPtr<nsIRegion> region(do_QueryInterface(aRegion));
00123        *isEqual = mRegion->IsEqual(*region);
00124        return NS_OK;
00125 }
00126 
00127 NS_IMETHODIMP nsScriptableRegion::GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
00128 {
00129        mRegion->GetBoundingBox(aX, aY, aWidth, aHeight);
00130        return NS_OK;
00131 }
00132 
00133 NS_IMETHODIMP nsScriptableRegion::Offset(PRInt32 aXOffset, PRInt32 aYOffset)
00134 {
00135        mRegion->Offset(aXOffset, aYOffset);
00136        return NS_OK;
00137 }
00138 
00139 NS_IMETHODIMP nsScriptableRegion::ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool *containsRect)
00140 {
00141        *containsRect = mRegion->ContainsRect(aX, aY, aWidth, aHeight);
00142        return NS_OK;
00143 }
00144 
00145 
00146 NS_IMETHODIMP nsScriptableRegion::GetRegion(nsIRegion** outRgn)
00147 {
00148   *outRgn = mRegion;
00149   NS_IF_ADDREF(*outRgn);
00150   return NS_OK;
00151 }