Back to index

lightning-sunbird  0.9+nobinonly
nsTreeColumns.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 nsTreeColumns_h__
00041 #define nsTreeColumns_h__
00042 
00043 #include "nsITreeColumns.h"
00044 #include "nsITreeBoxObject.h"
00045 #include "nsIContent.h"
00046 #include "nsIFrame.h"
00047 
00048 class nsTreeColumns;
00049 
00050 // This class is our column info.  We use it to iterate our columns and to obtain
00051 // information about each column.
00052 class nsTreeColumn : public nsITreeColumn {
00053 public:
00054   nsTreeColumn(nsTreeColumns* aColumns, nsIFrame* aFrame);
00055   ~nsTreeColumn();
00056 
00057   NS_DECL_ISUPPORTS
00058   NS_DECL_NSITREECOLUMN
00059 
00060   friend class nsTreeBodyFrame;
00061   friend class nsTreeColumns;
00062 
00063 protected:
00064   void CacheAttributes();
00065 
00066   nsIContent* GetContent() { return mFrame->GetContent(); };
00067 
00068   void SetColumns(nsTreeColumns* aColumns) { mColumns = aColumns; };
00069 
00070   PRInt32 GetX() { return mFrame->GetRect().x; };
00071   nscoord GetWidth() { return mFrame->GetRect().width; };
00072 
00073   const nsAString& GetId() { return mId; };
00074   nsIAtom* GetAtom() { return mAtom; };
00075 
00076   PRInt32 GetIndex() { return mIndex; };
00077 
00078   PRBool IsPrimary() { return mIsPrimary; };
00079   PRBool IsCycler() { return mIsCycler; };
00080   PRBool IsEditable() { return mIsEditable; };
00081 
00082   PRInt16 GetType() { return mType; };
00083 
00084   PRInt8 GetCropStyle() { return mCropStyle; };
00085   PRInt32 GetTextAlignment() { return mTextAlignment; };
00086 
00087   nsTreeColumn* GetNext() { return mNext; };
00088   nsTreeColumn* GetPrevious() { return mPrevious; };
00089   void SetNext(nsTreeColumn* aNext) { NS_IF_ADDREF(mNext = aNext); };
00090   void SetPrevious(nsTreeColumn* aPrevious) { mPrevious = aPrevious; };
00091 
00092 private:
00093   nsIFrame* mFrame;
00094 
00095   nsTreeColumns* mColumns;
00096 
00097   nsString mId;
00098   nsCOMPtr<nsIAtom> mAtom;
00099 
00100   PRInt32 mIndex;
00101 
00102   PRPackedBool mIsPrimary;
00103   PRPackedBool mIsCycler;
00104   PRPackedBool mIsEditable;
00105 
00106   PRInt16 mType;
00107 
00108   PRInt8 mCropStyle;
00109   PRInt8 mTextAlignment;
00110 
00111   nsTreeColumn* mNext;
00112   nsTreeColumn* mPrevious;
00113 };
00114 
00115 class nsTreeColumns : public nsITreeColumns {
00116 public:
00117   nsTreeColumns(nsITreeBoxObject* aTree);
00118   ~nsTreeColumns();
00119 
00120   NS_DECL_ISUPPORTS
00121   NS_DECL_NSITREECOLUMNS
00122 
00123   friend class nsTreeBodyFrame;
00124 protected:
00125   void SetTree(nsITreeBoxObject* aTree) { mTree = aTree; };
00126 
00127   // Builds our cache of column info.
00128   void EnsureColumns();
00129 
00130   nsTreeColumn* GetFirstColumn() { EnsureColumns(); return mFirstColumn; };
00131   nsTreeColumn* GetPrimaryColumn();
00132 
00133 private:
00134   nsITreeBoxObject* mTree;
00135 
00136   nsTreeColumn* mFirstColumn;
00137 };
00138 
00139 #endif // nsTreeColumns_h__