Back to index

lightning-sunbird  0.9+nobinonly
nsTreeImageListener.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) 2003
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Dave Hyatt <hyatt@mozilla.org> (Original Author)
00024  *   Jan Varga <varga@ku.sk>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * 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 #ifndef nsTreeImageListener_h__
00041 #define nsTreeImageListener_h__
00042 
00043 #include "nsString.h"
00044 #include "nsCOMPtr.h"
00045 #include "nsITreeColumns.h"
00046 #include "imgIDecoderObserver.h"
00047 
00048 class nsITreeBoxObject;
00049 
00050 // The interface for our image listener.
00051 // {90586540-2D50-403e-8DCE-981CAA778444}
00052 #define NS_ITREEIMAGELISTENER_IID \
00053 { 0x90586540, 0x2d50, 0x403e, { 0x8d, 0xce, 0x98, 0x1c, 0xaa, 0x77, 0x84, 0x44 } }
00054 
00055 class nsITreeImageListener : public nsISupports
00056 {
00057 public:
00058   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITREEIMAGELISTENER_IID)
00059 
00060   NS_IMETHOD AddCell(PRInt32 aIndex, nsITreeColumn* aCol) = 0;
00061 };
00062 
00063 // This class handles image load observation.
00064 class nsTreeImageListener : public imgIDecoderObserver, public nsITreeImageListener
00065 {
00066 public:
00067   nsTreeImageListener(nsITreeBoxObject* aTree);
00068   ~nsTreeImageListener();
00069 
00070   NS_DECL_ISUPPORTS
00071   NS_DECL_IMGIDECODEROBSERVER
00072   NS_DECL_IMGICONTAINEROBSERVER
00073 
00074   NS_IMETHOD AddCell(PRInt32 aIndex, nsITreeColumn* aCol);
00075  
00076   friend class nsTreeBodyFrame;
00077 
00078 protected:
00079   void UnsuppressInvalidation() { mInvalidationSuppressed = PR_FALSE; };
00080   void Invalidate();
00081 
00082 private:
00083   nsITreeBoxObject* mTree;
00084 
00085   // A guard that prevents us from recursive painting.
00086   PRBool mInvalidationSuppressed;
00087 
00088   class InvalidationArea {
00089     public:
00090       InvalidationArea(nsITreeColumn* aCol);
00091       ~InvalidationArea() { delete mNext; };
00092 
00093       friend class nsTreeImageListener;
00094 
00095     protected:
00096       void AddRow(PRInt32 aIndex);
00097       nsITreeColumn* GetCol() { return mCol.get(); };
00098       PRInt32 GetMin() { return mMin; };
00099       PRInt32 GetMax() { return mMax; };
00100       InvalidationArea* GetNext() { return mNext; };
00101       void SetNext(InvalidationArea* aNext) { mNext = aNext; };
00102 
00103     private:
00104       nsCOMPtr<nsITreeColumn> mCol;
00105       PRInt32                 mMin;
00106       PRInt32                 mMax;
00107       InvalidationArea*       mNext;
00108   };
00109 
00110   InvalidationArea* mInvalidationArea;
00111 };
00112 
00113 #endif // nsTreeImageListener_h__